[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: |
---|
[266] | 83 | StdSize getNStep(void) const; |
---|
| 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); |
---|
[707] | 92 | void resetNStep(StdSize 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: |
---|
[310] | 99 | bool isActive(void) 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); |
---|
[737] | 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); |
---|
[640] | 126 | |
---|
[651] | 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 | |
---|
[651] | 138 | template <int N> void setData(const CArray<double, N>& _data); |
---|
| 139 | static bool dispatchEvent(CEventServer& event); |
---|
[638] | 140 | void sendUpdateData(const CArray<double,1>& data); |
---|
[651] | 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); |
---|
[651] | 151 | void outputField(CArray<double,3>& fieldOut); |
---|
| 152 | void outputField(CArray<double,2>& fieldOut); |
---|
| 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); |
---|
[676] | 157 | void outputCompressedField(CArray<double, 1>& fieldOut); |
---|
[651] | 158 | void scaleFactorAddOffset(double scaleFactor, double addOffset); |
---|
[599] | 159 | void invertScaleFactorAddOffset(double scaleFactor, double addOffset); |
---|
[651] | 160 | void parse(xml::CXMLNode& node); |
---|
[509] | 161 | |
---|
[472] | 162 | void setVirtualVariableGroup(CVariableGroup* newVVariableGroup); |
---|
| 163 | void setVirtualVariableGroup(void); |
---|
| 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 | |
---|
[569] | 179 | const std::pair<StdString, StdString>& getRefDomainAxisIds(); |
---|
[619] | 180 | |
---|
[707] | 181 | public: |
---|
[219] | 182 | /// Propriétés privées /// |
---|
[651] | 183 | CVariableGroup* vVariableGroup; |
---|
[509] | 184 | |
---|
[651] | 185 | CGrid* grid; |
---|
[347] | 186 | CFile* file; |
---|
[219] | 187 | |
---|
[343] | 188 | CDuration freq_operation_srv, freq_write_srv; |
---|
[219] | 189 | |
---|
[707] | 190 | bool written; //<! Was the field written at least once |
---|
[599] | 191 | StdSize nstep, nstepMax; |
---|
| 192 | bool isEOF; |
---|
[651] | 193 | CDate lastlast_Write_srv, last_Write_srv, last_operation_srv; |
---|
[598] | 194 | CDate lastDataRequestedFromServer; |
---|
[509] | 195 | |
---|
[300] | 196 | map<int,boost::shared_ptr<func::CFunctor> > foperation_srv; |
---|
[509] | 197 | |
---|
[651] | 198 | map<int, CArray<double,1> > data_srv; |
---|
| 199 | string content; |
---|
[509] | 200 | |
---|
| 201 | bool areAllReferenceSolved; |
---|
[823] | 202 | bool isReferenceSolved; |
---|
[509] | 203 | std::pair<StdString,StdString> domAxisIds_; |
---|
[598] | 204 | bool isReadDataRequestPending; |
---|
[676] | 205 | bool useCompressedOutput; |
---|
[645] | 206 | |
---|
[540] | 207 | DECLARE_REF_FUNC(Field,field) |
---|
[219] | 208 | |
---|
[640] | 209 | private: |
---|
[645] | 210 | //! The type of operation attached to the field |
---|
| 211 | func::CFunctor::ETimeType operationTimeType; |
---|
| 212 | |
---|
[640] | 213 | //! The output pin of the filter providing the instant data for the field |
---|
| 214 | boost::shared_ptr<COutputPin> instantDataFilter; |
---|
[643] | 215 | //! The output pin of the filters providing the result of the field's temporal operation |
---|
| 216 | std::map<CDuration, boost::shared_ptr<COutputPin>, DurationFakeLessComparator> temporalDataFilters; |
---|
[737] | 217 | //! The output pin of the filter providing the instant data for self references |
---|
| 218 | boost::shared_ptr<COutputPin> selfReferenceFilter; |
---|
[640] | 219 | //! The source filter for data provided by the client |
---|
| 220 | boost::shared_ptr<CSourceFilter> clientSourceFilter; |
---|
| 221 | //! The source filter for data provided by the server |
---|
| 222 | boost::shared_ptr<CSourceFilter> serverSourceFilter; |
---|
| 223 | //! The terminal filter which stores the instant data |
---|
| 224 | boost::shared_ptr<CStoreFilter> storeFilter; |
---|
| 225 | //! The terminal filter which writes the data to file |
---|
| 226 | boost::shared_ptr<CFileWriterFilter> fileWriterFilter; |
---|
[219] | 227 | }; // class CField |
---|
| 228 | |
---|
| 229 | ///-------------------------------------------------------------- |
---|
| 230 | |
---|
| 231 | // Declare/Define CFieldGroup and CFieldDefinition |
---|
| 232 | DECLARE_GROUP(CField); |
---|
| 233 | |
---|
| 234 | ///----------------------------------------------------------------- |
---|
| 235 | |
---|
| 236 | template <> |
---|
| 237 | void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void); |
---|
| 238 | |
---|
| 239 | ///----------------------------------------------------------------- |
---|
[335] | 240 | } // namespace xios |
---|
[219] | 241 | |
---|
| 242 | |
---|
[591] | 243 | #endif // __XIOS_CField__ |
---|