[591] | 1 | #ifndef __XIOS_CField__ |
---|
| 2 | #define __XIOS_CField__ |
---|
[219] | 3 | |
---|
[591] | 4 | /// XIOS headers /// |
---|
| 5 | #include "xios_spl.hpp" |
---|
[219] | 6 | #include "group_factory.hpp" |
---|
| 7 | #include "functor.hpp" |
---|
| 8 | #include "functor_type.hpp" |
---|
| 9 | #include "duration.hpp" |
---|
| 10 | #include "date.hpp" |
---|
| 11 | #include "declare_group.hpp" |
---|
[231] | 12 | #include "calendar_util.hpp" |
---|
[369] | 13 | #include "array_new.hpp" |
---|
| 14 | #include "attribute_array.hpp" |
---|
[459] | 15 | #include "expr_node.hpp" |
---|
[540] | 16 | #include "declare_ref_func.hpp" |
---|
[619] | 17 | #include "transformation_enum.hpp" |
---|
[219] | 18 | |
---|
[300] | 19 | |
---|
[335] | 20 | namespace xios { |
---|
[509] | 21 | |
---|
[219] | 22 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
| 23 | |
---|
| 24 | class CFieldGroup; |
---|
| 25 | class CFieldAttributes; |
---|
| 26 | class CField; |
---|
| 27 | |
---|
| 28 | class CFile; |
---|
| 29 | class CGrid; |
---|
[300] | 30 | class CContext ; |
---|
[619] | 31 | class CGenericFilter; |
---|
| 32 | |
---|
[219] | 33 | ///-------------------------------------------------------------- |
---|
| 34 | |
---|
| 35 | // Declare/Define CFieldAttribute |
---|
| 36 | BEGIN_DECLARE_ATTRIBUTE_MAP(CField) |
---|
| 37 | # include "field_attribute.conf" |
---|
| 38 | END_DECLARE_ATTRIBUTE_MAP(CField) |
---|
| 39 | |
---|
| 40 | ///-------------------------------------------------------------- |
---|
| 41 | class CField |
---|
| 42 | : public CObjectTemplate<CField> |
---|
| 43 | , public CFieldAttributes |
---|
| 44 | { |
---|
| 45 | /// friend /// |
---|
| 46 | friend class CFile; |
---|
| 47 | |
---|
| 48 | /// typedef /// |
---|
| 49 | typedef CObjectTemplate<CField> SuperClass; |
---|
| 50 | typedef CFieldAttributes SuperClassAttribute; |
---|
| 51 | |
---|
| 52 | public : |
---|
| 53 | |
---|
| 54 | typedef CFieldAttributes RelAttributes; |
---|
| 55 | typedef CFieldGroup RelGroup; |
---|
| 56 | |
---|
[300] | 57 | enum EEventId |
---|
| 58 | { |
---|
[598] | 59 | EVENT_ID_UPDATE_DATA, EVENT_ID_READ_DATA, EVENT_ID_READ_DATA_READY, |
---|
| 60 | EVENT_ID_ADD_VARIABLE, EVENT_ID_ADD_VARIABLE_GROUP |
---|
[300] | 61 | } ; |
---|
[509] | 62 | |
---|
[219] | 63 | /// Constructeurs /// |
---|
| 64 | CField(void); |
---|
| 65 | explicit CField(const StdString & id); |
---|
| 66 | CField(const CField & field); // Not implemented yet. |
---|
| 67 | CField(const CField * const field); // Not implemented yet. |
---|
| 68 | |
---|
| 69 | /// Accesseurs /// |
---|
| 70 | |
---|
[347] | 71 | CGrid* getRelGrid(void) const ; |
---|
| 72 | CFile* getRelFile(void) const ; |
---|
[219] | 73 | |
---|
| 74 | public : |
---|
| 75 | |
---|
[266] | 76 | StdSize getNStep(void) const; |
---|
| 77 | |
---|
[343] | 78 | const CDuration & getFreqOperation(void) const; |
---|
| 79 | const CDuration & getFreqWrite(void) const; |
---|
[219] | 80 | |
---|
[343] | 81 | boost::shared_ptr<CDate> getLastWriteDate(void) const; |
---|
| 82 | boost::shared_ptr<CDate> getLastOperationDate(void) const; |
---|
[219] | 83 | |
---|
| 84 | boost::shared_ptr<func::CFunctor> getFieldOperation(void) const; |
---|
[509] | 85 | |
---|
[369] | 86 | CArray<double, 1> getData(void) const; |
---|
[593] | 87 | template <int N> void getData(CArray<double, N>& _data) const; |
---|
[219] | 88 | |
---|
| 89 | |
---|
| 90 | /// Mutateur /// |
---|
[347] | 91 | void setRelFile(CFile* _file); |
---|
[266] | 92 | void incrementNStep(void); |
---|
[321] | 93 | void resetNStep() ; |
---|
[599] | 94 | void resetNStepMax(); |
---|
[219] | 95 | |
---|
[369] | 96 | template <int N> bool updateData(const CArray<double, N>& data); |
---|
[619] | 97 | template <int N> bool updateFilteredData(CArray<double, N>& data); |
---|
| 98 | template<int N> |
---|
[620] | 99 | void updateDataWithoutOperation(const CArray<double, N>& _data, CArray<double,1>& updatedData); |
---|
[459] | 100 | bool updateDataFromExpression(const CArray<double, 1>& data); |
---|
[509] | 101 | void setDataFromExpression(const CArray<double, 1>& _data) ; |
---|
| 102 | |
---|
[219] | 103 | bool updateDataServer |
---|
[343] | 104 | (const CDate & currDate, |
---|
[369] | 105 | const std::deque< CArray<double, 1>* > storedClient); |
---|
[509] | 106 | |
---|
| 107 | std::map<int, StdSize> getGridDataSize(); |
---|
| 108 | |
---|
[300] | 109 | public : |
---|
[310] | 110 | bool isActive(void) const; |
---|
[459] | 111 | bool active ; |
---|
| 112 | bool hasOutputFile ; |
---|
[460] | 113 | bool hasFieldOut ; |
---|
[219] | 114 | |
---|
| 115 | /// Traitements /// |
---|
[459] | 116 | void processEnabledField(void) ; |
---|
[540] | 117 | |
---|
[219] | 118 | void solveGridReference(void); |
---|
| 119 | void solveOperation(void); |
---|
[509] | 120 | void solveCheckMaskIndex(bool doSendingIndex); |
---|
| 121 | void solveAllReferenceEnabledField(bool doSending2Sever); |
---|
| 122 | void buildAllExpressionEnabledField(); |
---|
| 123 | void solveGridDomainAxisRef(bool checkAtt); |
---|
[619] | 124 | void solveTransformedGrid(); |
---|
| 125 | CGrid* getGridRefOfBaseReference(); |
---|
[219] | 126 | |
---|
[369] | 127 | // virtual void fromBinary(StdIStream & is); |
---|
[219] | 128 | |
---|
| 129 | /// Destructeur /// |
---|
| 130 | virtual ~CField(void); |
---|
| 131 | |
---|
| 132 | /// Accesseurs statiques /// |
---|
| 133 | static StdString GetName(void); |
---|
| 134 | static StdString GetDefName(void); |
---|
[509] | 135 | |
---|
[219] | 136 | static ENodeType GetType(void); |
---|
[509] | 137 | |
---|
[369] | 138 | template <int N> void setData(const CArray<double, N>& _data) ; |
---|
[300] | 139 | static bool dispatchEvent(CEventServer& event) ; |
---|
| 140 | void sendUpdateData(void) ; |
---|
| 141 | static void recvUpdateData(CEventServer& event) ; |
---|
| 142 | void recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) ; |
---|
| 143 | void writeField(void) ; |
---|
[598] | 144 | void sendReadDataRequest(void); |
---|
| 145 | bool sendReadDataRequestIfNeeded(void); |
---|
| 146 | static void recvReadDataRequest(CEventServer& event); |
---|
| 147 | void recvReadDataRequest(void); |
---|
[599] | 148 | bool readField(void); |
---|
[598] | 149 | static void recvReadDataReady(CEventServer& event); |
---|
| 150 | void recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers); |
---|
[369] | 151 | void outputField(CArray<double,3>& fieldOut) ; |
---|
| 152 | void outputField(CArray<double,2>& fieldOut) ; |
---|
[567] | 153 | void outputField(CArray<double,1>& fieldOut) ; |
---|
[599] | 154 | void inputField(CArray<double,3>& fieldOut); |
---|
| 155 | void inputField(CArray<double,2>& fieldOut); |
---|
| 156 | void inputField(CArray<double,1>& fieldOut); |
---|
[464] | 157 | void scaleFactorAddOffset(double scaleFactor, double addOffset) ; |
---|
[599] | 158 | void invertScaleFactorAddOffset(double scaleFactor, double addOffset); |
---|
[459] | 159 | void parse(xml::CXMLNode & node) ; |
---|
| 160 | CArray<double,1>* getInstantData(void) ; |
---|
[509] | 161 | |
---|
[472] | 162 | void setVirtualVariableGroup(CVariableGroup* newVVariableGroup); |
---|
| 163 | void setVirtualVariableGroup(void); |
---|
| 164 | CVariableGroup* getVirtualVariableGroup(void) const; |
---|
| 165 | vector<CVariable*> getAllVariables(void) const; |
---|
| 166 | virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0); |
---|
[509] | 167 | |
---|
[472] | 168 | CVariable* addVariable(const string& id="") ; |
---|
| 169 | CVariableGroup* addVariableGroup(const string& id="") ; |
---|
| 170 | void sendAddVariable(const string& id="") ; |
---|
| 171 | void sendAddVariableGroup(const string& id="") ; |
---|
| 172 | static void recvAddVariable(CEventServer& event) ; |
---|
| 173 | void recvAddVariable(CBufferIn& buffer) ; |
---|
| 174 | static void recvAddVariableGroup(CEventServer& event) ; |
---|
| 175 | void recvAddVariableGroup(CBufferIn& buffer) ; |
---|
[509] | 176 | void sendAddAllVariables(); |
---|
| 177 | |
---|
| 178 | |
---|
[569] | 179 | const std::pair<StdString, StdString>& getRefDomainAxisIds(); |
---|
[619] | 180 | |
---|
| 181 | const std::vector<CField*>& getFilterSources(); |
---|
[620] | 182 | void applyFilter(const CArray<double, 1>& dataToSend, CArray<double,1>& dataToReceive); |
---|
| 183 | void sendAndReceiveTransformedData(const std::map<int, CArray<int,1>* >& localIndexToSend, |
---|
| 184 | const CArray<double, 1>& dataSrc, |
---|
| 185 | const std::map<int, std::vector<CArray<int,1>* > >& localIndexToReceive, |
---|
| 186 | CArray<double,1>& dataDest); |
---|
[300] | 187 | public : |
---|
[219] | 188 | /// Propriétés privées /// |
---|
[472] | 189 | CVariableGroup* vVariableGroup ; |
---|
[509] | 190 | |
---|
[347] | 191 | CGrid* grid ; |
---|
| 192 | CFile* file; |
---|
[460] | 193 | CField* fieldOut ; |
---|
[219] | 194 | |
---|
[343] | 195 | CDuration freq_operation, freq_write; |
---|
| 196 | CDuration freq_operation_srv, freq_write_srv; |
---|
[219] | 197 | |
---|
[599] | 198 | StdSize nstep, nstepMax; |
---|
| 199 | bool isEOF; |
---|
[343] | 200 | boost::shared_ptr<CDate> last_Write, last_operation; |
---|
| 201 | boost::shared_ptr<CDate> lastlast_Write_srv,last_Write_srv, last_operation_srv; |
---|
[598] | 202 | CDate lastDataRequestedFromServer; |
---|
[509] | 203 | |
---|
[219] | 204 | boost::shared_ptr<func::CFunctor> foperation; |
---|
[300] | 205 | map<int,boost::shared_ptr<func::CFunctor> > foperation_srv; |
---|
[509] | 206 | |
---|
[369] | 207 | CArray<double, 1> data; |
---|
[459] | 208 | CArray<double, 1> instantData; |
---|
[619] | 209 | CArray<double, 1> filteredData; |
---|
[459] | 210 | bool hasInstantData ; |
---|
[369] | 211 | map<int, CArray<double,1>* > data_srv ; |
---|
[436] | 212 | bool isOnceOperation ; |
---|
| 213 | bool isFirstOperation ; |
---|
[459] | 214 | string content ; |
---|
[509] | 215 | |
---|
[459] | 216 | list< pair<CField *,int> > fieldDependency ; |
---|
| 217 | void buildExpression(void) ; |
---|
| 218 | void addDependency(CField* field, int slotId) ; |
---|
| 219 | void resetSlots(void) ; |
---|
| 220 | vector<bool> slots ; |
---|
| 221 | CDate* slotUpdateDate ; |
---|
| 222 | CFieldNode * expression ; |
---|
| 223 | bool hasExpression ; |
---|
| 224 | bool slotsFull(void) ; |
---|
| 225 | void setSlot(int slotId); |
---|
| 226 | bool processed ; |
---|
[509] | 227 | bool areAllReferenceSolved; |
---|
| 228 | bool areAllExpressionBuilt; |
---|
| 229 | std::pair<StdString,StdString> domAxisIds_; |
---|
[598] | 230 | bool isReadDataRequestPending; |
---|
[619] | 231 | std::vector<CField*> filterSources_; |
---|
[540] | 232 | DECLARE_REF_FUNC(Field,field) |
---|
[219] | 233 | |
---|
| 234 | }; // class CField |
---|
| 235 | |
---|
| 236 | ///-------------------------------------------------------------- |
---|
| 237 | |
---|
| 238 | // Declare/Define CFieldGroup and CFieldDefinition |
---|
| 239 | DECLARE_GROUP(CField); |
---|
| 240 | |
---|
| 241 | ///----------------------------------------------------------------- |
---|
| 242 | |
---|
| 243 | template <> |
---|
| 244 | void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void); |
---|
| 245 | |
---|
| 246 | ///----------------------------------------------------------------- |
---|
[335] | 247 | } // namespace xios |
---|
[219] | 248 | |
---|
| 249 | |
---|
[591] | 250 | #endif // __XIOS_CField__ |
---|