source: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.hpp @ 1875

Last change on this file since 1875 was 1875, checked in by ymipsl, 4 years ago

XIOS coupling branch
Some updates.

First coupling test is beginning to work...

YM

File size: 5.2 KB
Line 
1#ifndef __XIOS_CScalar__
2#define __XIOS_CScalar__
3
4/// XIOS headers ///
5#include "xios_spl.hpp"
6#include "declare_group.hpp"
7#include "declare_ref_func.hpp"
8#include "group_template.hpp"
9#include "array_new.hpp"
10#include "attribute_enum.hpp"
11#include "attribute_enum_impl.hpp"
12#include "attribute_array.hpp"
13#include "transformation.hpp"
14#include "transformation_enum.hpp"
15
16namespace xios
17{
18      /// ////////////////////// Déclarations ////////////////////// ///
19
20      class CScalarGroup;
21      class CScalarAttributes;
22      class CScalar;
23      ///--------------------------------------------------------------
24
25      // Declare/Define CVarAttribute
26      BEGIN_DECLARE_ATTRIBUTE_MAP(CScalar)
27#include "scalar_attribute.conf"
28      END_DECLARE_ATTRIBUTE_MAP(CScalar)
29
30      ///--------------------------------------------------------------
31
32      class CScalar
33         : public CObjectTemplate<CScalar>
34         , public CScalarAttributes
35      {
36            /// typedef ///
37            typedef CObjectTemplate<CScalar>   SuperClass;
38            typedef CScalarAttributes SuperClassAttribute;
39
40            friend class CScalarGroup;
41
42         public :
43
44            typedef CScalarAttributes RelAttributes;
45            typedef CScalarGroup      RelGroup;
46            typedef CTransformation<CScalar>::TransformationMapTypes TransMapTypes;
47
48            /// Constructeurs ///
49            CScalar(void);
50            explicit CScalar(const StdString & id);
51            CScalar(const CScalar & var);       // Not implemented yet.
52            CScalar(const CScalar * const var); // Not implemented yet.
53
54            /// Destructeur ///
55            virtual ~CScalar(void);
56
57         public :
58            /// Accesseurs statiques ///
59            static StdString GetName(void);
60            static StdString GetDefName(void);
61            static ENodeType GetType(void);
62
63         public:
64            static CScalar* createScalar();
65
66         public:
67            void checkAttributes(void);
68            bool checkAttributes_done_ = false ;
69           
70            void addRelFile(const StdString& filename);
71            bool IsWritten(const StdString& filename) const;
72            void checkAttributesOnClient();
73            virtual void parse(xml::CXMLNode & node);
74       
75         public:
76            void sendScalarToFileServer(CContextClient* client) ;
77         private:
78            std::set<CContextClient*> sendScalarToFileServer_done_ ;
79
80         public:
81            void sendScalarToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid) ;
82         private:
83            std::set<CContextClient*> sendScalarToCouplerOut_done_ ;
84         
85         public:
86            void makeAliasForCoupling(const string& fieldId, int posInGrid) ;
87
88         public:
89           bool hasTransformation();
90           void solveInheritanceTransformation();
91           TransMapTypes getAllTransformations();
92           void duplicateTransformation(CScalar*);
93           CTransformation<CScalar>* addTransformation(ETranformationType transType, const StdString& id="");
94           bool isEqual(CScalar* scalar);
95        private: 
96          /** Clients that have to send a scalar. There can be multiple clients in case of secondary server, otherwise only one client. */
97         std::list<CContextClient*> clients;
98         std::set<CContextClient*> clientsSet;
99        public:
100          void setContextClient(CContextClient* contextClient) ;
101       
102         private:
103           std::set<StdString> relFiles;
104           TransMapTypes transformationMap_;
105
106            void setTransformations(const TransMapTypes&);
107
108       private:
109           static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
110           static std::map<StdString, ETranformationType> transformationMapList_;
111           static bool dummyTransformationMapList_;
112
113           /** define if the scalar is completed or not ie all attributes have been received before in case
114               of grid reading from file or coupling */ 
115      private:
116         /** define if the scalar is completed or not ie all attributes have been received before in case
117             of grid reading from file or coupling */ 
118         bool isCompleted_=true ; 
119      public:     
120         /*!
121           \brief Check if a scalar is completed
122           Before make any scalar processing, we must be sure that all scalar informations have
123           been sent, for exemple when reading a grid in a file or when grid elements are sent by an
124           other context (coupling). So all direct reference of the scalar (scalar_ref) must be also completed
125           \return true if scalar and scalar reference are completed
126          */
127         bool isCompleted(void)
128         {
129           if (hasDirectScalarReference()) if (!getDirectScalarReference()->isCompleted()) return false;
130           else return isCompleted_ ;
131         }
132         void setCompleted(void) { isCompleted_=true ; }
133         void unsetCompleted(void) { isCompleted_=false ; }
134
135      private:
136            DECLARE_REF_FUNC(Scalar,scalar)
137
138      }; // class CVar
139      ///--------------------------------------------------------------
140
141      // Declare/Define CScalarGroup and CScalarDefinition
142      DECLARE_GROUP(CScalar);
143} // namespace xios
144
145#endif // __XIOS_CScalar__
Note: See TracBrowser for help on using the repository browser.