FTypedLeaf.hpp 1.98 KB
Newer Older
1
// ===================================================================================
2 3 4 5 6 7 8 9
// Logiciel initial: ScalFmm Version 0.5
// Co-auteurs : Olivier Coulaud, Bérenger Bramas.
// Propriétaires : INRIA.
// Copyright © 2011-2012, diffusé sous les termes et conditions d’une licence propriétaire.
// Initial software: ScalFmm Version 0.5
// Co-authors: Olivier Coulaud, Bérenger Bramas.
// Owners: INRIA.
// Copyright © 2011-2012, spread under the terms and conditions of a proprietary license.
10
// ===================================================================================
11 12
#ifndef FTYPEDLEAF_HPP
#define FTYPEDLEAF_HPP
13

14 15 16 17 18 19 20 21 22 23 24 25

#include "../Utils/FAssertable.hpp"
#include "FAbstractLeaf.hpp"

/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FTypedLeaf
* @brief
* Please read the license
* This class is used to enable the use of typed particles
* (source XOR target) or simple system (source AND target)
*/
berenger-bramas's avatar
berenger-bramas committed
26
template< class ParticleClass , class ContainerClass>
27
class FTypedLeaf  : public FAbstractLeaf<ParticleClass,ContainerClass>, public FAssertable {
berenger-bramas's avatar
berenger-bramas committed
28 29
    ContainerClass sources;
    ContainerClass targets;
30 31 32 33 34 35 36 37 38 39

public:
    /** Default destructor */
    virtual ~FTypedLeaf(){
    }

    /**
        * To add a new particle in the leaf
        * @param particle the new particle
        */
40
    void push(const ParticleClass& particle){
berenger-bramas's avatar
berenger-bramas committed
41 42
        if(particle.isTarget()) this->targets.push(particle);
        else if(particle.isSource()) this->sources.push(particle);
43
        else fassert(false, "Error particle has undefined type.", __LINE__, __FILE__);
44 45 46 47 48 49
    }

    /**
        * To get all the sources in a leaf
        * @return a pointer to the list of particles that are sources
        */
berenger-bramas's avatar
berenger-bramas committed
50
    ContainerClass* getSrc() {
51 52 53 54 55 56 57
        return &this->sources;
    }

    /**
        * To get all the target in a leaf
        * @return a pointer to the list of particles that are targets
        */
berenger-bramas's avatar
berenger-bramas committed
58
    ContainerClass* getTargets() {
59 60 61 62 63 64 65 66
        return &this->targets;
    }

};


#endif //FTYPEDLEAF_HPP

67