source: XIOS/trunk/src/object_template.hpp @ 1114

Last change on this file since 1114 was 1105, checked in by mhnguyen, 7 years ago

Adding comparison operator between objects of XIOS.
Two objects of a same type are considered equal if they have same non-empty
attributes which have same values

+) Add operator== to class CArray
+) Add comparison operator to some basic attribute classes
+) Add operator== to date and duration (It seems that they don't serve much)

Test
+) On Curie
+) No Unit tests but test with transformation work (the next commit)

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 3.6 KB
RevLine 
[591]1#ifndef __XIOS_CObjectTemplate__
2#define __XIOS_CObjectTemplate__
[219]3
[591]4/// XIOS headers ///
5#include "xios_spl.hpp"
[219]6#include "attribute_map.hpp"
7#include "node_enum.hpp"
[300]8#include "buffer_in.hpp"
9#include "event_server.hpp"
10#include "attribute.hpp"
[219]11
[335]12namespace xios
[219]13{
14   /// ////////////////////// Déclarations ////////////////////// ///
15   template <class T>
16      class CObjectTemplate
17         : public CObject
[345]18         , public virtual CAttributeMap
[219]19   {
20
21         /// Friend ///
22         friend class CObjectFactory;
23
24         /// Typedef ///
[345]25         typedef CAttributeMap SuperClassMap;
[219]26         typedef CObject SuperClass;
27         typedef T DerivedType;
[509]28
[300]29         enum EEventId
30         {
31           EVENT_ID_SEND_ATTRIBUTE=100
32         } ;
[219]33
34      public :
35
36         /// Autres ///
37         virtual StdString toString(void) const;
38         virtual void fromString(const StdString & str);
39
[369]40//         virtual void toBinary  (StdOStream & os) const;
41//         virtual void fromBinary(StdIStream & is);
[313]42         virtual string getName(void) const ;
[219]43         virtual void parse(xml::CXMLNode & node);
[509]44
[219]45         /// Accesseurs ///
[345]46         ENodeType getType(void) const;
[219]47
48         /// Test ///
49         virtual bool hasChild(void) const;
50
51         /// Traitements ///
[445]52         virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0);
[219]53
54         /// Traitement statique ///
55         static void ClearAllAttributes(void);
[731]56         std::map<int, size_t> getMinimumBufferSizeForAttributes();
[300]57         void sendAttributToServer(const string& id);
[345]58         void sendAttributToServer(CAttribute& attr) ;
[509]59         void sendAllAttributesToServer();
[300]60         static void recvAttributFromClient(CEventServer& event) ;
61         static bool dispatchEvent(CEventServer& event) ;
[219]62
[1105]63         bool isEqual(const string& id);
64         bool isEqual(T* obj);
65
[219]66         /// Accesseur statique ///
67         static std::vector<boost::shared_ptr<DerivedType> > &
68            GetAllVectobject(const StdString & contextId);
69
70         /// Destructeur ///
71         virtual ~CObjectTemplate(void);
[509]72
[300]73         static bool has(const string& id) ;
[346]74         static bool has(const string& contextId, const string& id) ;
[347]75         static T* get(const string& id) ;
76         static T* get(const T* ptr) ;
77         static T* get(const string& contextId, const string& id) ;
78         T* get(void) ;
79         shared_ptr<T> getShared(void) ;
80         static shared_ptr<T> getShared(const T* ptr) ;
[509]81
[347]82         static T* create(const string& id=string("")) ;
83         static const vector<T*> getAll() ;
84         static const vector<T*> getAll(const string& contextId) ;
[509]85
[313]86         void generateCInterface(ostream& oss) ;
87         void generateFortran2003Interface(ostream& oss) ;
88         void generateFortranInterface(ostream& oss) ;
[509]89
[219]90      protected :
91
92         /// Constructeurs ///
93         CObjectTemplate(void);
94         explicit CObjectTemplate(const StdString & id);
95         CObjectTemplate(const CObjectTemplate<T> & object,
96                         bool withAttrList = true, bool withId = true);
97         CObjectTemplate(const CObjectTemplate<T> * const object); // Not implemented.
98
99      private :
100
101         /// Propriétés statiques ///
102         static xios_map<StdString,
103                xios_map<StdString,
[509]104                boost::shared_ptr<DerivedType> > > AllMapObj;
[219]105         static xios_map<StdString,
106                std::vector<boost::shared_ptr<DerivedType> > > AllVectObj;
[509]107
[286]108         static xios_map< StdString, long int > GenId ;
[219]109
110   }; // class CObjectTemplate
[335]111} // namespace xios
[219]112
[300]113//#include "object_template_impl.hpp"
114
[591]115#endif // __XIOS_CObjectTemplate__
Note: See TracBrowser for help on using the repository browser.