[219] | 1 | #ifndef __XMLIO_CField__ |
---|
| 2 | #define __XMLIO_CField__ |
---|
| 3 | |
---|
[335] | 4 | /// xios headers /// |
---|
[219] | 5 | #include "xmlioserver_spl.hpp" |
---|
| 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" |
---|
[300] | 16 | //#include "context.hpp" |
---|
[219] | 17 | |
---|
[300] | 18 | |
---|
[335] | 19 | namespace xios { |
---|
[219] | 20 | |
---|
| 21 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
| 22 | |
---|
| 23 | class CFieldGroup; |
---|
| 24 | class CFieldAttributes; |
---|
| 25 | class CField; |
---|
| 26 | |
---|
| 27 | class CFile; |
---|
| 28 | class CGrid; |
---|
[300] | 29 | class CContext ; |
---|
[219] | 30 | ///-------------------------------------------------------------- |
---|
| 31 | |
---|
| 32 | // Declare/Define CFieldAttribute |
---|
| 33 | BEGIN_DECLARE_ATTRIBUTE_MAP(CField) |
---|
| 34 | # include "field_attribute.conf" |
---|
| 35 | END_DECLARE_ATTRIBUTE_MAP(CField) |
---|
| 36 | |
---|
| 37 | ///-------------------------------------------------------------- |
---|
| 38 | class CField |
---|
| 39 | : public CObjectTemplate<CField> |
---|
| 40 | , public CFieldAttributes |
---|
| 41 | { |
---|
| 42 | /// friend /// |
---|
| 43 | friend class CFile; |
---|
| 44 | |
---|
| 45 | /// typedef /// |
---|
| 46 | typedef CObjectTemplate<CField> SuperClass; |
---|
| 47 | typedef CFieldAttributes SuperClassAttribute; |
---|
| 48 | |
---|
| 49 | public : |
---|
| 50 | |
---|
| 51 | typedef CFieldAttributes RelAttributes; |
---|
| 52 | typedef CFieldGroup RelGroup; |
---|
| 53 | |
---|
[300] | 54 | enum EEventId |
---|
| 55 | { |
---|
| 56 | EVENT_ID_UPDATE_DATA |
---|
| 57 | } ; |
---|
| 58 | |
---|
[219] | 59 | /// Constructeurs /// |
---|
| 60 | CField(void); |
---|
| 61 | explicit CField(const StdString & id); |
---|
| 62 | CField(const CField & field); // Not implemented yet. |
---|
| 63 | CField(const CField * const field); // Not implemented yet. |
---|
| 64 | |
---|
| 65 | /// Accesseurs /// |
---|
[347] | 66 | CField* getDirectFieldReference(void) const; |
---|
| 67 | CField* getBaseFieldReference(void) const; |
---|
[459] | 68 | void addReference(CField* field) ; |
---|
[347] | 69 | const std::vector<CField*> & getAllReference(void) const; |
---|
[219] | 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; |
---|
| 85 | |
---|
[369] | 86 | CArray<double, 1> getData(void) const; |
---|
[219] | 87 | |
---|
| 88 | const StdString & getBaseFieldId(void) const; |
---|
| 89 | |
---|
| 90 | /// Mutateur /// |
---|
[347] | 91 | void setRelFile(CFile* _file); |
---|
[266] | 92 | void incrementNStep(void); |
---|
[321] | 93 | void resetNStep() ; |
---|
[219] | 94 | |
---|
[369] | 95 | template <int N> bool updateData(const CArray<double, N>& data); |
---|
[459] | 96 | bool updateDataFromExpression(const CArray<double, 1>& data); |
---|
[300] | 97 | |
---|
[219] | 98 | bool updateDataServer |
---|
[343] | 99 | (const CDate & currDate, |
---|
[369] | 100 | const std::deque< CArray<double, 1>* > storedClient); |
---|
[300] | 101 | |
---|
| 102 | public : |
---|
[219] | 103 | |
---|
| 104 | /// Test /// |
---|
| 105 | bool hasDirectFieldReference(void) const; |
---|
[310] | 106 | bool isActive(void) const; |
---|
[459] | 107 | bool active ; |
---|
| 108 | bool hasOutputFile ; |
---|
[219] | 109 | |
---|
| 110 | /// Traitements /// |
---|
[459] | 111 | void processEnabledField(void) ; |
---|
[445] | 112 | void solveRefInheritance(bool apply); |
---|
[219] | 113 | void solveGridReference(void); |
---|
| 114 | void solveOperation(void); |
---|
| 115 | |
---|
[369] | 116 | // virtual void fromBinary(StdIStream & is); |
---|
[219] | 117 | |
---|
| 118 | /// Destructeur /// |
---|
| 119 | virtual ~CField(void); |
---|
| 120 | |
---|
| 121 | /// Accesseurs statiques /// |
---|
| 122 | static StdString GetName(void); |
---|
| 123 | static StdString GetDefName(void); |
---|
| 124 | |
---|
| 125 | static ENodeType GetType(void); |
---|
[300] | 126 | |
---|
[369] | 127 | template <int N> void setData(const CArray<double, N>& _data) ; |
---|
[300] | 128 | static bool dispatchEvent(CEventServer& event) ; |
---|
| 129 | void sendUpdateData(void) ; |
---|
| 130 | static void recvUpdateData(CEventServer& event) ; |
---|
| 131 | void recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) ; |
---|
| 132 | void writeField(void) ; |
---|
[369] | 133 | void outputField(CArray<double,3>& fieldOut) ; |
---|
| 134 | void outputField(CArray<double,2>& fieldOut) ; |
---|
[459] | 135 | void parse(xml::CXMLNode & node) ; |
---|
| 136 | CArray<double,1>* getInstantData(void) ; |
---|
[300] | 137 | public : |
---|
[219] | 138 | |
---|
| 139 | /// Propriétés privées /// |
---|
| 140 | |
---|
[347] | 141 | std::vector<CField*> refObject; |
---|
| 142 | CField* baseRefObject; |
---|
| 143 | CGrid* grid ; |
---|
| 144 | CFile* file; |
---|
[219] | 145 | |
---|
[343] | 146 | CDuration freq_operation, freq_write; |
---|
| 147 | CDuration freq_operation_srv, freq_write_srv; |
---|
[219] | 148 | |
---|
[266] | 149 | StdSize nstep; |
---|
[343] | 150 | boost::shared_ptr<CDate> last_Write, last_operation; |
---|
| 151 | boost::shared_ptr<CDate> lastlast_Write_srv,last_Write_srv, last_operation_srv; |
---|
[300] | 152 | |
---|
[219] | 153 | boost::shared_ptr<func::CFunctor> foperation; |
---|
[300] | 154 | map<int,boost::shared_ptr<func::CFunctor> > foperation_srv; |
---|
[219] | 155 | |
---|
[369] | 156 | CArray<double, 1> data; |
---|
[459] | 157 | CArray<double, 1> instantData; |
---|
| 158 | bool hasInstantData ; |
---|
[369] | 159 | map<int, CArray<double,1>* > data_srv ; |
---|
[436] | 160 | bool isOnceOperation ; |
---|
| 161 | bool isFirstOperation ; |
---|
[459] | 162 | string content ; |
---|
| 163 | |
---|
| 164 | list< pair<CField *,int> > fieldDependency ; |
---|
| 165 | void buildExpression(void) ; |
---|
| 166 | void addDependency(CField* field, int slotId) ; |
---|
| 167 | void resetSlots(void) ; |
---|
| 168 | vector<bool> slots ; |
---|
| 169 | CDate* slotUpdateDate ; |
---|
| 170 | CFieldNode * expression ; |
---|
| 171 | bool hasExpression ; |
---|
| 172 | bool slotsFull(void) ; |
---|
| 173 | void setSlot(int slotId); |
---|
| 174 | bool processed ; |
---|
[219] | 175 | |
---|
| 176 | }; // class CField |
---|
| 177 | |
---|
| 178 | ///-------------------------------------------------------------- |
---|
| 179 | |
---|
| 180 | // Declare/Define CFieldGroup and CFieldDefinition |
---|
| 181 | DECLARE_GROUP(CField); |
---|
| 182 | |
---|
| 183 | ///----------------------------------------------------------------- |
---|
| 184 | |
---|
| 185 | template <> |
---|
| 186 | void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void); |
---|
| 187 | |
---|
| 188 | ///----------------------------------------------------------------- |
---|
[335] | 189 | } // namespace xios |
---|
[219] | 190 | |
---|
| 191 | |
---|
| 192 | #endif // __XMLIO_CField__ |
---|