source: XIOS/dev/branch_openmp/src/object_template.hpp @ 1538

Last change on this file since 1538 was 1460, checked in by yushan, 6 years ago

branch_openmp merged with XIOS_DEV_CMIP6@1459

  • 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: 4.2 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"
[1460]11#include "context_client.hpp"
[219]12
[335]13namespace xios
[219]14{
[1460]15   /// ////////////////////// Déclarations ////////////////////// ///
16   template <class T>
17      class CObjectTemplate
18         : public CObject
19         , public virtual CAttributeMap
20   {
[219]21
[1460]22         /// Friend ///
23         friend class CObjectFactory;
[219]24
[1460]25         /// Typedef ///
26         typedef CAttributeMap SuperClassMap;
27         typedef CObject SuperClass;
28         typedef T DerivedType;
[509]29
[1460]30         enum EEventId
31         {
32           EVENT_ID_SEND_ATTRIBUTE=100
33         } ;
[219]34
[1460]35      public :
[219]36
[1460]37         /// Autres ///
38         virtual StdString toString(void) const;
39         virtual void fromString(const StdString & str);
[219]40
[1460]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);
[509]45
[1460]46         /// Accesseurs ///
47         ENodeType getType(void) const;
[219]48
[1460]49         /// Test ///
50         virtual bool hasChild(void) const;
[219]51
[1460]52         /// Traitements ///
53         virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0);
[219]54
[1460]55         /// Traitement statique ///
56         static void ClearAllAttributes(void);
57         std::map<int, size_t> getMinimumBufferSizeForAttributes(CContextClient* client);
58         void sendAttributToServer(const string& id);
59         void sendAttributToServer(const string& id, CContextClient* client);
60         void sendAttributToServer(CAttribute& attr) ;
61         void sendAttributToServer(CAttribute& attr, CContextClient* client) ;
62         void sendAllAttributesToServer();
63         void sendAllAttributesToServer(CContextClient* client);
64         void sendAddItem(const string& id, int itemType);
65         void sendAddItem(const string& id, int itemType, CContextClient* client);
66         static void recvAttributFromClient(CEventServer& event) ;
67         static bool dispatchEvent(CEventServer& event) ;
[219]68
[1460]69         bool isEqual(const string& id, const vector<StdString>& excludedAttrs);
70         bool isEqual(T* obj, const vector<StdString>& excludedAttrs);
[1105]71
[1460]72         /// Accesseur statique ///
73         static std::vector<boost::shared_ptr<DerivedType> > &
74            GetAllVectobject(const StdString & contextId);
[219]75
[1460]76         /// Destructeur ///
77         virtual ~CObjectTemplate(void);
[509]78
[1460]79         static bool has(const string& id) ;
80         static bool has(const string& contextId, const string& id) ;
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         boost::shared_ptr<T> getShared(void) ;
86         static boost::shared_ptr<T> getShared(const T* ptr) ;
[509]87
[1460]88         static T* create(const string& id=string("")) ;
89         static const vector<T*> getAll() ;
90         static const vector<T*> getAll(const string& contextId) ;
[1334]91
[1460]92         void generateCInterface(ostream& oss) ;
93         void generateFortran2003Interface(ostream& oss) ;
94         void generateFortranInterface(ostream& oss) ;
[509]95
[1460]96      protected :
[509]97
[1460]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.
[219]104
[1460]105      private :
[219]106
[1460]107         /// Propriétés statiques ///
108         static xios_map<StdString,
109                xios_map<StdString,
110                boost::shared_ptr<DerivedType> > > *AllMapObj_ptr;
111         #pragma omp threadprivate(AllMapObj_ptr)
112         static xios_map<StdString,
113                std::vector<boost::shared_ptr<DerivedType> > > *AllVectObj_ptr;
114         #pragma omp threadprivate(AllVectObj_ptr)
[219]115
[1460]116         static xios_map< StdString, long int > *GenId_ptr ;
117         #pragma omp threadprivate(GenId_ptr)
[509]118
[1460]119   }; // class CObjectTemplate
[335]120} // namespace xios
[219]121
[300]122//#include "object_template_impl.hpp"
123
[591]124#endif // __XIOS_CObjectTemplate__
Note: See TracBrowser for help on using the repository browser.