Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:51:49

0001 #ifndef MODULE_OBJECT_REFERENCE_H
0002 #define MODULE_OBJECT_REFERENCE_H
0003 
0004 /**
0005  * @file ModuleObjectReference.h
0006  * @author Bryan BERTHOU (SPhN / CEA Saclay)
0007  * @date November 23, 2016
0008  * @version 1.0
0009  */
0010 
0011 #include <string>
0012 
0013 #include "BaseObject.h"
0014 
0015 namespace PARTONS {
0016 
0017 class ModuleObject;
0018 
0019 /**
0020  * @class ModuleObjectReference
0021  */
0022 class ModuleObjectReference: public BaseObject {
0023 public:
0024 
0025     /**
0026      *
0027      * @param pModuleObjectPointer
0028      */
0029     ModuleObjectReference(ModuleObject* pModuleObjectPointer);
0030 
0031     /**
0032      * Copy constructor
0033      *
0034      * @param other
0035      */
0036     ModuleObjectReference(const ModuleObjectReference &other);
0037 
0038     /**
0039      * Default destructor
0040      *
0041      * In the ModuleObjectFactory when test is done on the m_numberOfReference member, if it reached 0 (zero) then it means that there is no longer reference to the m_pModuleObjectPointer member.
0042      * So the current ModuleObjectReference in the ModuleFactory map is deleted and the destructor of ModuleObjectReference is called.
0043      * And object pointed by m_pModuleObjectPointer is removed from the memory (see destructor implementation).
0044      */
0045     virtual ~ModuleObjectReference();
0046 
0047     /**
0048      * Increment by one the number of reference to the pointed object m_pModuleObjectPointer;
0049      */
0050     void incCounter();
0051 
0052     /**
0053      * Decrement by one the number of reference to the pointed object m_pModuleObjectPointer;
0054      */
0055     void decCounter();
0056 
0057     virtual std::string toString() const;
0058 
0059     unsigned int getNumberOfReference() const;
0060     void setNumberOfReference(unsigned int numberOfReference);
0061     const ModuleObject* getModuleObjectPointer() const;
0062 
0063 private:
0064     ModuleObject* m_pModuleObjectPointer; ///< Keep pointer to the module object in memory.
0065 
0066     unsigned int m_numberOfReference; ///< Count the number of reference to the pointer member in the all running program.
0067 };
0068 
0069 } /* namespace PARTONS */
0070 
0071 #endif /* MODULE_OBJECT_REFERENCE_H */