source: XIOS/dev/dev_ym/XIOS_COUPLING/src/object_template.hpp @ 2203

Last change on this file since 2203 was 2203, checked in by ymipsl, 3 years ago

New functionnality : domain, axis and scalar can now be retrieve with new syntax id :
ex. for domain :

id="domainId" : old syntax, working as before
id="fieldId::domainId" : get the domain related to "domainId" associated to the field "fieldId", work if only 1 domain related to domainId is associated to the field.
id="fieldId::domainId[n]" : get the nth domain related to "domainId" associated to the field "fieldId"
id="fieldId::" : get the domain associated the the field "fieldId, work if grid associated to th field is composed with exactly 1 domain (and possibly other components axis or scalars)
id="fieldId::[n] : get the nth domain composing the grid associated to the field

YM

  • 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: 5.1 KB
Line 
1#ifndef __XIOS_CObjectTemplate__
2#define __XIOS_CObjectTemplate__
3
4/// XIOS headers ///
5#include "xios_spl.hpp"
6#include "attribute_map.hpp"
7#include "node_enum.hpp"
8#include "buffer_in.hpp"
9#include "event_server.hpp"
10#include "attribute.hpp"
11#include "context_client.hpp"
12
13namespace xios
14{
15   /// ////////////////////// Déclarations ////////////////////// ///
16   template <class T>
17      class CObjectTemplate
18         : public CObject
19         , public virtual CAttributeMap
20   {
21
22         /// Friend ///
23         friend class CObjectFactory;
24
25         /// Typedef ///
26         typedef CAttributeMap SuperClassMap;
27         typedef CObject SuperClass;
28         typedef T DerivedType;
29
30         enum EEventId
31         {
32           EVENT_ID_SEND_ATTRIBUTE=100
33         } ;
34
35      public :
36
37         /// Autres ///
38         virtual StdString toString(void) const;
39         virtual void fromString(const StdString & str);
40
41//         virtual void toBinary  (StdOStream & os) const;
42//         virtual void fromBinary(StdIStream & is);
43         virtual string getName(void) const ;
44         virtual void parse(xml::CXMLNode & node);
45
46         /// Accesseurs ///
47         ENodeType getType(void) const;
48
49         /// Test ///
50         virtual bool hasChild(void) const;
51
52         /// Traitements ///
53         virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0);
54 
55         /// Traitement statique ///
56         static void ClearAllAttributes(void);
57         std::map<int, size_t> getMinimumBufferSizeForAttributes(CContextClient* client);
58         void sendAttributToServer(const string& id, CContextClient* client, const string& objectId="");
59         void sendAttributToServer(CAttribute& attr, CContextClient* client, const string& objectId="") ;
60         void sendAllAttributesToServer(CContextClient* client, const string& objectId="");
61         void sendAddItem(const string& id, int itemType, CContextClient* client, const string& objectId="");
62         static void recvAttributFromClient(CEventServer& event) ;
63         static bool dispatchEvent(CEventServer& event) ;
64
65         bool isEqual(const string& id, const vector<StdString>& excludedAttrs);
66         bool isEqual(T* obj, const vector<StdString>& excludedAttrs);
67
68         /// Accesseur statique ///
69         static std::vector<std::shared_ptr<DerivedType> > &
70            GetAllVectobject(const StdString & contextId);
71
72         /// Destructeur ///
73         virtual ~CObjectTemplate(void);
74
75         static bool has(const string& id) ;
76         static bool has(const string& contextId, const string& id) ;
77         static T* get(const string& id) ;
78         static T* get(const T* ptr) ;
79         static T* get(const string& contextId, const string& id) ;
80         T* get(void) ;
81         std::shared_ptr<T> getShared(void) ;
82         static std::shared_ptr<T> getShared(const T* ptr) ;
83
84         static T* create(const string& id=string("")) ;
85         static T* createAlias(const string& id, const string& alias) ;
86         void createAlias(const string& alias) ;
87
88         static const vector<T*> getAll() ;
89         static const vector<T*> getAll(const string& contextId) ;
90
91         void generateCInterface(ostream& oss) ;
92         void generateFortran2003Interface(ostream& oss) ;
93         void generateFortranInterface(ostream& oss) ;
94     
95      // manage inherited id which is herited by reference
96        void setInheritedId(T* obj) ;
97        bool hasInheritedId(void) { return hasInheritedId_ ;}
98        string getInheritedId(void) { return  inheritedId_ ;}
99
100      private: 
101         std::string inheritedId_ ;
102         bool hasInheritedId_ = false;
103
104      // manage the template id
105      public:
106         void setTemplateId(T* obj) ; //<! set the id of the object that served as template
107         bool hasTemplateId(void) {return hasTemplateId_;} //<! return  hasTemplateId_
108         string getTemplateId(void)
109         {
110           if (hasTemplateId_) return templateId_  ;
111           else if (hasId() && !hasAutoGeneratedId()) return getId() ;
112           else if (hasInheritedId()) return getInheritedId() ;
113           else return getId() ;
114         }
115      private:
116         std::string templateId_ ;    //<! the id of the object that served as template
117         bool hasTemplateId_ = false; //<! true if templateId is set
118     
119      protected :
120
121         /// Constructeurs ///
122         CObjectTemplate(void);
123         explicit CObjectTemplate(const StdString & id);
124         CObjectTemplate(const CObjectTemplate<T> & object,
125                         bool withAttrList = true, bool withId = true);
126         CObjectTemplate(const CObjectTemplate<T> * const object); // Not implemented.
127
128      private :
129
130         /// Propriétés statiques ///
131         static xios_map<StdString,
132                xios_map<StdString,
133                std::shared_ptr<DerivedType> > > AllMapObj;
134         static xios_map<StdString,
135                std::vector<std::shared_ptr<DerivedType> > > AllVectObj;
136
137         static xios_map< StdString, long int > GenId ;
138
139   }; // class CObjectTemplate
140} // namespace xios
141
142//#include "object_template_impl.hpp"
143
144#endif // __XIOS_CObjectTemplate__
Note: See TracBrowser for help on using the repository browser.