[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" |
---|
[1021] | 11 | #include "context_client.hpp" |
---|
[219] | 12 | |
---|
[335] | 13 | namespace xios |
---|
[219] | 14 | { |
---|
| 15 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
| 16 | template <class T> |
---|
| 17 | class CObjectTemplate |
---|
| 18 | : public CObject |
---|
[345] | 19 | , public virtual CAttributeMap |
---|
[219] | 20 | { |
---|
| 21 | |
---|
| 22 | /// Friend /// |
---|
| 23 | friend class CObjectFactory; |
---|
| 24 | |
---|
| 25 | /// Typedef /// |
---|
[345] | 26 | typedef CAttributeMap SuperClassMap; |
---|
[219] | 27 | typedef CObject SuperClass; |
---|
| 28 | typedef T DerivedType; |
---|
[509] | 29 | |
---|
[300] | 30 | enum EEventId |
---|
| 31 | { |
---|
| 32 | EVENT_ID_SEND_ATTRIBUTE=100 |
---|
| 33 | } ; |
---|
[219] | 34 | |
---|
| 35 | public : |
---|
| 36 | |
---|
| 37 | /// Autres /// |
---|
| 38 | virtual StdString toString(void) const; |
---|
| 39 | virtual void fromString(const StdString & str); |
---|
| 40 | |
---|
[369] | 41 | // virtual void toBinary (StdOStream & os) const; |
---|
| 42 | // virtual void fromBinary(StdIStream & is); |
---|
[313] | 43 | virtual string getName(void) const ; |
---|
[219] | 44 | virtual void parse(xml::CXMLNode & node); |
---|
[509] | 45 | |
---|
[219] | 46 | /// Accesseurs /// |
---|
[345] | 47 | ENodeType getType(void) const; |
---|
[219] | 48 | |
---|
| 49 | /// Test /// |
---|
| 50 | virtual bool hasChild(void) const; |
---|
| 51 | |
---|
| 52 | /// Traitements /// |
---|
[445] | 53 | virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0); |
---|
[219] | 54 | |
---|
| 55 | /// Traitement statique /// |
---|
| 56 | static void ClearAllAttributes(void); |
---|
[1330] | 57 | std::map<int, size_t> getMinimumBufferSizeForAttributes(CContextClient* client); |
---|
[300] | 58 | void sendAttributToServer(const string& id); |
---|
[1021] | 59 | void sendAttributToServer(const string& id, CContextClient* client); |
---|
[345] | 60 | void sendAttributToServer(CAttribute& attr) ; |
---|
[1021] | 61 | void sendAttributToServer(CAttribute& attr, CContextClient* client) ; |
---|
[509] | 62 | void sendAllAttributesToServer(); |
---|
[1021] | 63 | void sendAllAttributesToServer(CContextClient* client); |
---|
[987] | 64 | void sendAddItem(const string& id, int itemType); |
---|
[1021] | 65 | void sendAddItem(const string& id, int itemType, CContextClient* client); |
---|
[300] | 66 | static void recvAttributFromClient(CEventServer& event) ; |
---|
| 67 | static bool dispatchEvent(CEventServer& event) ; |
---|
[219] | 68 | |
---|
[1158] | 69 | bool isEqual(const string& id, const vector<StdString>& excludedAttrs); |
---|
| 70 | bool isEqual(T* obj, const vector<StdString>& excludedAttrs); |
---|
| 71 | |
---|
[219] | 72 | /// Accesseur statique /// |
---|
| 73 | static std::vector<boost::shared_ptr<DerivedType> > & |
---|
| 74 | GetAllVectobject(const StdString & contextId); |
---|
| 75 | |
---|
| 76 | /// Destructeur /// |
---|
| 77 | virtual ~CObjectTemplate(void); |
---|
[509] | 78 | |
---|
[300] | 79 | static bool has(const string& id) ; |
---|
[346] | 80 | static bool has(const string& contextId, const string& id) ; |
---|
[347] | 81 | static T* get(const string& id) ; |
---|
| 82 | static T* get(const T* ptr) ; |
---|
| 83 | static T* get(const string& contextId, const string& id) ; |
---|
| 84 | T* get(void) ; |
---|
| 85 | shared_ptr<T> getShared(void) ; |
---|
| 86 | static shared_ptr<T> getShared(const T* ptr) ; |
---|
[509] | 87 | |
---|
[347] | 88 | static T* create(const string& id=string("")) ; |
---|
| 89 | static const vector<T*> getAll() ; |
---|
| 90 | static const vector<T*> getAll(const string& contextId) ; |
---|
[509] | 91 | |
---|
[313] | 92 | void generateCInterface(ostream& oss) ; |
---|
| 93 | void generateFortran2003Interface(ostream& oss) ; |
---|
| 94 | void generateFortranInterface(ostream& oss) ; |
---|
[509] | 95 | |
---|
[219] | 96 | protected : |
---|
| 97 | |
---|
| 98 | /// Constructeurs /// |
---|
| 99 | CObjectTemplate(void); |
---|
| 100 | explicit CObjectTemplate(const StdString & id); |
---|
| 101 | CObjectTemplate(const CObjectTemplate<T> & object, |
---|
| 102 | bool withAttrList = true, bool withId = true); |
---|
| 103 | CObjectTemplate(const CObjectTemplate<T> * const object); // Not implemented. |
---|
| 104 | |
---|
| 105 | private : |
---|
| 106 | |
---|
| 107 | /// Propriétés statiques /// |
---|
| 108 | static xios_map<StdString, |
---|
| 109 | xios_map<StdString, |
---|
[509] | 110 | boost::shared_ptr<DerivedType> > > AllMapObj; |
---|
[219] | 111 | static xios_map<StdString, |
---|
| 112 | std::vector<boost::shared_ptr<DerivedType> > > AllVectObj; |
---|
[509] | 113 | |
---|
[286] | 114 | static xios_map< StdString, long int > GenId ; |
---|
[219] | 115 | |
---|
| 116 | }; // class CObjectTemplate |
---|
[335] | 117 | } // namespace xios |
---|
[219] | 118 | |
---|
[300] | 119 | //#include "object_template_impl.hpp" |
---|
| 120 | |
---|
[591] | 121 | #endif // __XIOS_CObjectTemplate__ |
---|