[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" |
---|
[540] | 15 | #include "declare_ref_func.hpp" |
---|
[619] | 16 | #include "transformation_enum.hpp" |
---|
[646] | 17 | #include "variable.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; |
---|
[640] | 30 | class CContext; |
---|
[619] | 31 | class CGenericFilter; |
---|
| 32 | |
---|
[640] | 33 | class CGarbageCollector; |
---|
| 34 | class COutputPin; |
---|
| 35 | class CSourceFilter; |
---|
| 36 | class CStoreFilter; |
---|
| 37 | class CFileWriterFilter; |
---|
| 38 | |
---|
[219] | 39 | ///-------------------------------------------------------------- |
---|
| 40 | |
---|
| 41 | // Declare/Define CFieldAttribute |
---|
| 42 | BEGIN_DECLARE_ATTRIBUTE_MAP(CField) |
---|
| 43 | # include "field_attribute.conf" |
---|
| 44 | END_DECLARE_ATTRIBUTE_MAP(CField) |
---|
| 45 | |
---|
| 46 | ///-------------------------------------------------------------- |
---|
| 47 | class CField |
---|
| 48 | : public CObjectTemplate<CField> |
---|
| 49 | , public CFieldAttributes |
---|
| 50 | { |
---|
| 51 | /// friend /// |
---|
| 52 | friend class CFile; |
---|
| 53 | |
---|
| 54 | /// typedef /// |
---|
| 55 | typedef CObjectTemplate<CField> SuperClass; |
---|
| 56 | typedef CFieldAttributes SuperClassAttribute; |
---|
| 57 | |
---|
[707] | 58 | public: |
---|
[219] | 59 | |
---|
| 60 | typedef CFieldAttributes RelAttributes; |
---|
| 61 | typedef CFieldGroup RelGroup; |
---|
| 62 | |
---|
[300] | 63 | enum EEventId |
---|
| 64 | { |
---|
[598] | 65 | EVENT_ID_UPDATE_DATA, EVENT_ID_READ_DATA, EVENT_ID_READ_DATA_READY, |
---|
| 66 | EVENT_ID_ADD_VARIABLE, EVENT_ID_ADD_VARIABLE_GROUP |
---|
[651] | 67 | }; |
---|
[509] | 68 | |
---|
[219] | 69 | /// Constructeurs /// |
---|
| 70 | CField(void); |
---|
[651] | 71 | explicit CField(const StdString& id); |
---|
| 72 | CField(const CField& field); // Not implemented yet. |
---|
| 73 | CField(const CField* const field); // Not implemented yet. |
---|
[219] | 74 | |
---|
| 75 | /// Accesseurs /// |
---|
| 76 | |
---|
[651] | 77 | CGrid* getRelGrid(void) const; |
---|
| 78 | CFile* getRelFile(void) const; |
---|
[219] | 79 | |
---|
[645] | 80 | func::CFunctor::ETimeType getOperationTimeType() const; |
---|
| 81 | |
---|
[707] | 82 | public: |
---|
[952] | 83 | int getNStep(void) const; |
---|
[266] | 84 | |
---|
[593] | 85 | template <int N> void getData(CArray<double, N>& _data) const; |
---|
[219] | 86 | |
---|
[641] | 87 | boost::shared_ptr<COutputPin> getInstantDataFilter(); |
---|
[219] | 88 | |
---|
| 89 | /// Mutateur /// |
---|
[347] | 90 | void setRelFile(CFile* _file); |
---|
[266] | 91 | void incrementNStep(void); |
---|
[952] | 92 | void resetNStep(int nstep = 0); |
---|
[599] | 93 | void resetNStepMax(); |
---|
[219] | 94 | |
---|
[731] | 95 | std::map<int, StdSize> getGridAttributesBufferSize(); |
---|
| 96 | std::map<int, StdSize> getGridDataBufferSize(); |
---|
[509] | 97 | |
---|
[707] | 98 | public: |
---|
[1119] | 99 | bool isActive(bool atCurrentTimestep = false) const; |
---|
[651] | 100 | bool hasOutputFile; |
---|
[219] | 101 | |
---|
[707] | 102 | bool wasWritten() const; |
---|
| 103 | void setWritten(); |
---|
| 104 | |
---|
[676] | 105 | bool getUseCompressedOutput() const; |
---|
| 106 | void setUseCompressedOutput(); |
---|
| 107 | |
---|
[219] | 108 | /// Traitements /// |
---|
| 109 | void solveGridReference(void); |
---|
[645] | 110 | void solveServerOperation(void); |
---|
[509] | 111 | void solveCheckMaskIndex(bool doSendingIndex); |
---|
[823] | 112 | void solveAllReferenceEnabledField(bool doSending2Server); |
---|
| 113 | void solveOnlyReferenceEnabledField(bool doSending2Server); |
---|
| 114 | void generateNewTransformationGridDest(); |
---|
| 115 | void updateRef(CGrid* grid); |
---|
| 116 | void buildGridTransformationGraph(); |
---|
[509] | 117 | void solveGridDomainAxisRef(bool checkAtt); |
---|
[619] | 118 | void solveTransformedGrid(); |
---|
[687] | 119 | void solveGenerateGrid(); |
---|
[775] | 120 | void solveGridDomainAxisBaseRef(); |
---|
[219] | 121 | |
---|
[640] | 122 | void buildFilterGraph(CGarbageCollector& gc, bool enableOutput); |
---|
[1000] | 123 | boost::shared_ptr<COutputPin> getFieldReference(CGarbageCollector& gc); |
---|
[642] | 124 | boost::shared_ptr<COutputPin> getSelfReference(CGarbageCollector& gc); |
---|
[643] | 125 | boost::shared_ptr<COutputPin> getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq); |
---|
[998] | 126 | boost::shared_ptr<COutputPin> getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq); |
---|
[640] | 127 | |
---|
[651] | 128 | // virtual void fromBinary(StdIStream& is); |
---|
[219] | 129 | |
---|
| 130 | /// Destructeur /// |
---|
| 131 | virtual ~CField(void); |
---|
| 132 | |
---|
| 133 | /// Accesseurs statiques /// |
---|
| 134 | static StdString GetName(void); |
---|
| 135 | static StdString GetDefName(void); |
---|
[509] | 136 | |
---|
[219] | 137 | static ENodeType GetType(void); |
---|
[509] | 138 | |
---|
[651] | 139 | template <int N> void setData(const CArray<double, N>& _data); |
---|
| 140 | static bool dispatchEvent(CEventServer& event); |
---|
[638] | 141 | void sendUpdateData(const CArray<double,1>& data); |
---|
[651] | 142 | static void recvUpdateData(CEventServer& event); |
---|
| 143 | void recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers); |
---|
| 144 | void writeField(void); |
---|
[1017] | 145 | bool sendReadDataRequest(const CDate& tsDataRequested); |
---|
[598] | 146 | bool sendReadDataRequestIfNeeded(void); |
---|
| 147 | static void recvReadDataRequest(CEventServer& event); |
---|
| 148 | void recvReadDataRequest(void); |
---|
[599] | 149 | bool readField(void); |
---|
[598] | 150 | static void recvReadDataReady(CEventServer& event); |
---|
| 151 | void recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers); |
---|
[651] | 152 | void outputField(CArray<double,3>& fieldOut); |
---|
| 153 | void outputField(CArray<double,2>& fieldOut); |
---|
| 154 | void outputField(CArray<double,1>& fieldOut); |
---|
[599] | 155 | void inputField(CArray<double,3>& fieldOut); |
---|
| 156 | void inputField(CArray<double,2>& fieldOut); |
---|
| 157 | void inputField(CArray<double,1>& fieldOut); |
---|
[676] | 158 | void outputCompressedField(CArray<double, 1>& fieldOut); |
---|
[651] | 159 | void scaleFactorAddOffset(double scaleFactor, double addOffset); |
---|
[599] | 160 | void invertScaleFactorAddOffset(double scaleFactor, double addOffset); |
---|
[651] | 161 | void parse(xml::CXMLNode& node); |
---|
[509] | 162 | |
---|
[472] | 163 | void setVirtualVariableGroup(CVariableGroup* newVVariableGroup); |
---|
| 164 | CVariableGroup* getVirtualVariableGroup(void) const; |
---|
| 165 | vector<CVariable*> getAllVariables(void) const; |
---|
[651] | 166 | virtual void solveDescInheritance(bool apply, const CAttributeMap* const parent = 0); |
---|
[509] | 167 | |
---|
[651] | 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 | |
---|
[887] | 179 | const std::vector<StdString>& getRefDomainAxisIds(); |
---|
[619] | 180 | |
---|
[1000] | 181 | const string& getExpression(void); |
---|
| 182 | bool hasExpression(void) const; |
---|
| 183 | |
---|
[707] | 184 | public: |
---|
[219] | 185 | /// Propriétés privées /// |
---|
[651] | 186 | CVariableGroup* vVariableGroup; |
---|
[509] | 187 | |
---|
[651] | 188 | CGrid* grid; |
---|
[347] | 189 | CFile* file; |
---|
[219] | 190 | |
---|
[343] | 191 | CDuration freq_operation_srv, freq_write_srv; |
---|
[219] | 192 | |
---|
[707] | 193 | bool written; //<! Was the field written at least once |
---|
[952] | 194 | int nstep, nstepMax; |
---|
[599] | 195 | bool isEOF; |
---|
[651] | 196 | CDate lastlast_Write_srv, last_Write_srv, last_operation_srv; |
---|
[1013] | 197 | CDate lastDataRequestedFromServer, lastDataReceivedFromServer; |
---|
| 198 | bool wasDataAlreadyReceivedFromServer; |
---|
[509] | 199 | |
---|
[300] | 200 | map<int,boost::shared_ptr<func::CFunctor> > foperation_srv; |
---|
[509] | 201 | |
---|
[651] | 202 | map<int, CArray<double,1> > data_srv; |
---|
| 203 | string content; |
---|
[509] | 204 | |
---|
| 205 | bool areAllReferenceSolved; |
---|
[823] | 206 | bool isReferenceSolved; |
---|
[887] | 207 | std::vector<StdString> domAxisScalarIds_; |
---|
[676] | 208 | bool useCompressedOutput; |
---|
[645] | 209 | |
---|
[989] | 210 | // Two variable to identify the time_counter meta data written in file, which has no time_counter |
---|
| 211 | bool hasTimeInstant; |
---|
| 212 | bool hasTimeCentered; |
---|
| 213 | |
---|
[540] | 214 | DECLARE_REF_FUNC(Field,field) |
---|
[219] | 215 | |
---|
[640] | 216 | private: |
---|
[645] | 217 | //! The type of operation attached to the field |
---|
| 218 | func::CFunctor::ETimeType operationTimeType; |
---|
| 219 | |
---|
[640] | 220 | //! The output pin of the filter providing the instant data for the field |
---|
| 221 | boost::shared_ptr<COutputPin> instantDataFilter; |
---|
[643] | 222 | //! The output pin of the filters providing the result of the field's temporal operation |
---|
| 223 | std::map<CDuration, boost::shared_ptr<COutputPin>, DurationFakeLessComparator> temporalDataFilters; |
---|
[737] | 224 | //! The output pin of the filter providing the instant data for self references |
---|
| 225 | boost::shared_ptr<COutputPin> selfReferenceFilter; |
---|
[640] | 226 | //! The source filter for data provided by the client |
---|
| 227 | boost::shared_ptr<CSourceFilter> clientSourceFilter; |
---|
| 228 | //! The source filter for data provided by the server |
---|
| 229 | boost::shared_ptr<CSourceFilter> serverSourceFilter; |
---|
| 230 | //! The terminal filter which stores the instant data |
---|
| 231 | boost::shared_ptr<CStoreFilter> storeFilter; |
---|
| 232 | //! The terminal filter which writes the data to file |
---|
| 233 | boost::shared_ptr<CFileWriterFilter> fileWriterFilter; |
---|
[219] | 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__ |
---|