[887] | 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" |
---|
[1436] | 12 | #include "attribute_array.hpp" |
---|
[887] | 13 | #include "transformation.hpp" |
---|
| 14 | #include "transformation_enum.hpp" |
---|
| 15 | |
---|
[1930] | 16 | #include "element.hpp" |
---|
| 17 | #include "local_connector.hpp" |
---|
| 18 | #include "scatterer_connector.hpp" |
---|
| 19 | #include "gatherer_connector.hpp" |
---|
| 20 | #include "distribution_type.hpp" |
---|
| 21 | |
---|
| 22 | |
---|
[887] | 23 | namespace xios |
---|
| 24 | { |
---|
| 25 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
| 26 | |
---|
| 27 | class CScalarGroup; |
---|
| 28 | class CScalarAttributes; |
---|
| 29 | class CScalar; |
---|
| 30 | ///-------------------------------------------------------------- |
---|
| 31 | |
---|
| 32 | // Declare/Define CVarAttribute |
---|
| 33 | BEGIN_DECLARE_ATTRIBUTE_MAP(CScalar) |
---|
| 34 | #include "scalar_attribute.conf" |
---|
| 35 | END_DECLARE_ATTRIBUTE_MAP(CScalar) |
---|
| 36 | |
---|
| 37 | ///-------------------------------------------------------------- |
---|
| 38 | |
---|
| 39 | class CScalar |
---|
| 40 | : public CObjectTemplate<CScalar> |
---|
| 41 | , public CScalarAttributes |
---|
| 42 | { |
---|
[1940] | 43 | friend class CScalarGroup; |
---|
| 44 | |
---|
[887] | 45 | /// typedef /// |
---|
| 46 | typedef CObjectTemplate<CScalar> SuperClass; |
---|
| 47 | typedef CScalarAttributes SuperClassAttribute; |
---|
| 48 | |
---|
[1940] | 49 | public: |
---|
| 50 | enum EEventId |
---|
| 51 | { |
---|
| 52 | EVENT_ID_SCALAR_DISTRIBUTION, |
---|
| 53 | EVENT_ID_SEND_DISTRIBUTED_ATTRIBUTE, |
---|
| 54 | } ; |
---|
| 55 | static bool dispatchEvent(CEventServer& event); |
---|
| 56 | |
---|
[887] | 57 | |
---|
| 58 | public : |
---|
| 59 | |
---|
| 60 | typedef CScalarAttributes RelAttributes; |
---|
| 61 | typedef CScalarGroup RelGroup; |
---|
| 62 | typedef CTransformation<CScalar>::TransformationMapTypes TransMapTypes; |
---|
| 63 | |
---|
| 64 | /// Constructeurs /// |
---|
| 65 | CScalar(void); |
---|
| 66 | explicit CScalar(const StdString & id); |
---|
| 67 | CScalar(const CScalar & var); // Not implemented yet. |
---|
| 68 | CScalar(const CScalar * const var); // Not implemented yet. |
---|
| 69 | |
---|
| 70 | /// Destructeur /// |
---|
| 71 | virtual ~CScalar(void); |
---|
| 72 | |
---|
| 73 | public : |
---|
| 74 | /// Accesseurs statiques /// |
---|
| 75 | static StdString GetName(void); |
---|
| 76 | static StdString GetDefName(void); |
---|
| 77 | static ENodeType GetType(void); |
---|
| 78 | |
---|
| 79 | public: |
---|
| 80 | static CScalar* createScalar(); |
---|
| 81 | |
---|
| 82 | public: |
---|
| 83 | void checkAttributes(void); |
---|
[1869] | 84 | bool checkAttributes_done_ = false ; |
---|
| 85 | |
---|
[887] | 86 | void addRelFile(const StdString& filename); |
---|
| 87 | bool IsWritten(const StdString& filename) const; |
---|
[1975] | 88 | virtual void parse(xml::CXMLNode & node); |
---|
[1875] | 89 | |
---|
[1870] | 90 | public: |
---|
[1875] | 91 | void sendScalarToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid) ; |
---|
| 92 | private: |
---|
| 93 | std::set<CContextClient*> sendScalarToCouplerOut_done_ ; |
---|
| 94 | |
---|
| 95 | public: |
---|
| 96 | void makeAliasForCoupling(const string& fieldId, int posInGrid) ; |
---|
| 97 | |
---|
| 98 | public: |
---|
[887] | 99 | bool hasTransformation(); |
---|
| 100 | void solveInheritanceTransformation(); |
---|
| 101 | TransMapTypes getAllTransformations(); |
---|
| 102 | void duplicateTransformation(CScalar*); |
---|
| 103 | CTransformation<CScalar>* addTransformation(ETranformationType transType, const StdString& id=""); |
---|
[1158] | 104 | bool isEqual(CScalar* scalar); |
---|
[1875] | 105 | private: |
---|
| 106 | /** Clients that have to send a scalar. There can be multiple clients in case of secondary server, otherwise only one client. */ |
---|
| 107 | std::list<CContextClient*> clients; |
---|
| 108 | std::set<CContextClient*> clientsSet; |
---|
| 109 | public: |
---|
| 110 | void setContextClient(CContextClient* contextClient) ; |
---|
| 111 | |
---|
[887] | 112 | private: |
---|
| 113 | std::set<StdString> relFiles; |
---|
[1158] | 114 | TransMapTypes transformationMap_; |
---|
[887] | 115 | |
---|
| 116 | void setTransformations(const TransMapTypes&); |
---|
[888] | 117 | |
---|
| 118 | private: |
---|
| 119 | static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); |
---|
| 120 | static std::map<StdString, ETranformationType> transformationMapList_; |
---|
| 121 | static bool dummyTransformationMapList_; |
---|
| 122 | |
---|
[1869] | 123 | /** define if the scalar is completed or not ie all attributes have been received before in case |
---|
| 124 | of grid reading from file or coupling */ |
---|
[1875] | 125 | private: |
---|
| 126 | /** define if the scalar is completed or not ie all attributes have been received before in case |
---|
| 127 | of grid reading from file or coupling */ |
---|
| 128 | bool isCompleted_=true ; |
---|
| 129 | public: |
---|
| 130 | /*! |
---|
| 131 | \brief Check if a scalar is completed |
---|
| 132 | Before make any scalar processing, we must be sure that all scalar informations have |
---|
| 133 | been sent, for exemple when reading a grid in a file or when grid elements are sent by an |
---|
| 134 | other context (coupling). So all direct reference of the scalar (scalar_ref) must be also completed |
---|
| 135 | \return true if scalar and scalar reference are completed |
---|
| 136 | */ |
---|
| 137 | bool isCompleted(void) |
---|
| 138 | { |
---|
| 139 | if (hasDirectScalarReference()) if (!getDirectScalarReference()->isCompleted()) return false; |
---|
| 140 | else return isCompleted_ ; |
---|
| 141 | } |
---|
| 142 | void setCompleted(void) { isCompleted_=true ; } |
---|
| 143 | void unsetCompleted(void) { isCompleted_=false ; } |
---|
[888] | 144 | |
---|
[1930] | 145 | |
---|
| 146 | |
---|
| 147 | ////////////////////////////////////////////////////////////////////////////////////// |
---|
| 148 | // this part is related to distribution, element definition, views and connectors // |
---|
| 149 | ////////////////////////////////////////////////////////////////////////////////////// |
---|
| 150 | private: |
---|
| 151 | CLocalElement* localElement_ = nullptr ; |
---|
| 152 | void initializeLocalElement(void) ; |
---|
| 153 | |
---|
| 154 | public: |
---|
| 155 | CLocalElement* getLocalElement(void) { if (localElement_==nullptr) initializeLocalElement() ; return localElement_ ; } |
---|
| 156 | CLocalView* getLocalView(CElementView::type type) { return getLocalElement()->getView(type) ;} |
---|
| 157 | |
---|
| 158 | private: |
---|
| 159 | void addFullView(void) ; |
---|
| 160 | void addWorkflowView(void) ; |
---|
| 161 | void addModelView(void) ; |
---|
| 162 | |
---|
| 163 | private: |
---|
| 164 | CLocalConnector* modelToWorkflowConnector_ ; |
---|
| 165 | void computeModelToWorkflowConnector(void) ; |
---|
| 166 | public: |
---|
| 167 | CLocalConnector* getModelToWorkflowConnector(void) { if (modelToWorkflowConnector_==nullptr) computeModelToWorkflowConnector() ; return modelToWorkflowConnector_ ;} |
---|
| 168 | |
---|
| 169 | public: |
---|
| 170 | void computeRemoteElement(CContextClient* client, EDistributionType) ; |
---|
[1958] | 171 | void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndex, CScattererConnector* &scattererConnector, |
---|
| 172 | const string& scalarId="") ; |
---|
| 173 | |
---|
[1940] | 174 | static void recvScalarDistribution(CEventServer& event) ; |
---|
| 175 | void receivedScalarDistribution(CEventServer& event, int phasis) ; |
---|
[1943] | 176 | void setServerMask(CArray<bool,1>& serverMask, CContextClient* client) ; |
---|
[1940] | 177 | void sendDistributedAttributes(CContextClient* client, CScattererConnector& scattererConnector, const string& scalarId) ; |
---|
| 178 | static void recvDistributedAttributes(CEventServer& event) ; |
---|
| 179 | void recvDistributedAttributes(CEventServer& event, const string& type) ; |
---|
| 180 | |
---|
[1930] | 181 | private: |
---|
| 182 | map<CContextClient*, CDistributedElement*> remoteElement_ ; |
---|
| 183 | public: |
---|
| 184 | CDistributedElement* getRemoteElement(CContextClient* client) {return remoteElement_[client] ;} |
---|
| 185 | private: |
---|
| 186 | map<CContextClient*, CScattererConnector*> clientToServerConnector_ ; |
---|
| 187 | public: |
---|
| 188 | CScattererConnector* getClientToServerConnector(CContextClient* client) { return clientToServerConnector_[client] ;} |
---|
| 189 | |
---|
| 190 | private: |
---|
| 191 | CGathererConnector* gathererConnector_ ; |
---|
[1943] | 192 | public: |
---|
| 193 | CGathererConnector* getGathererConnector(void) { return gathererConnector_ ;} |
---|
| 194 | private: |
---|
[1930] | 195 | CGathererConnector* serverFromClientConnector_ ; |
---|
[1940] | 196 | CDistributedElement* elementFrom_ ; |
---|
[1930] | 197 | public: |
---|
| 198 | CGathererConnector* getServerFromClientConnector(void) { return serverFromClientConnector_ ;} |
---|
| 199 | |
---|
[1934] | 200 | private: |
---|
| 201 | CScattererConnector* serverToClientConnector_ = nullptr ; |
---|
| 202 | public: |
---|
| 203 | CScattererConnector* getServerToClientConnector(void) { return serverToClientConnector_ ;} |
---|
[1930] | 204 | |
---|
[1934] | 205 | private: |
---|
| 206 | map<CContextClient*,CGathererConnector*> clientFromServerConnector_ ; |
---|
| 207 | public: |
---|
| 208 | CGathererConnector* getClientFromServerConnector(CContextClient* client) { return clientFromServerConnector_[client] ;} |
---|
[1930] | 209 | |
---|
[1875] | 210 | private: |
---|
[887] | 211 | DECLARE_REF_FUNC(Scalar,scalar) |
---|
| 212 | |
---|
| 213 | }; // class CVar |
---|
| 214 | ///-------------------------------------------------------------- |
---|
| 215 | |
---|
| 216 | // Declare/Define CScalarGroup and CScalarDefinition |
---|
| 217 | DECLARE_GROUP(CScalar); |
---|
| 218 | } // namespace xios |
---|
| 219 | |
---|
| 220 | #endif // __XIOS_CScalar__ |
---|