source: XMLIO_V2/dev/dev_rv/src/xmlio/node/field.hpp @ 206

Last change on this file since 206 was 206, checked in by hozdoba, 13 years ago
File size: 4.7 KB
Line 
1#ifndef __XMLIO_CField__
2#define __XMLIO_CField__
3
4/// xmlioserver headers ///
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"
12
13namespace xmlioserver {
14namespace tree {
15   
16   /// ////////////////////// Déclarations ////////////////////// ///
17
18   class CFieldGroup;
19   class CFieldAttributes;
20   class CField;
21
22   class CFile;
23   class CGrid;
24
25   ///--------------------------------------------------------------
26
27   // Declare/Define CFieldAttribute
28   BEGIN_DECLARE_ATTRIBUTE_MAP(CField)
29#  include "field_attribute.conf"
30   END_DECLARE_ATTRIBUTE_MAP(CField)
31
32   ///--------------------------------------------------------------
33   class CField
34      : public CObjectTemplate<CField>
35      , public CFieldAttributes
36   {
37         /// friend ///
38         friend class CFile;
39
40         /// typedef ///
41         typedef CObjectTemplate<CField>   SuperClass;
42         typedef CFieldAttributes SuperClassAttribute;
43
44      public :
45
46         typedef CFieldAttributes RelAttributes;
47         typedef CFieldGroup      RelGroup;
48
49         /// Constructeurs ///
50         CField(void);
51         explicit CField(const StdString & id);
52         CField(const CField & field);       // Not implemented yet.
53         CField(const CField * const field); // Not implemented yet.
54
55         /// Accesseurs ///
56         boost::shared_ptr<CField> getDirectFieldReference(void) const;
57         const boost::shared_ptr<CField> getBaseFieldReference(void) const;
58         const std::vector<boost::shared_ptr<CField> > & getAllReference(void) const;
59
60         boost::shared_ptr<CGrid> getRelGrid(void) const ;
61         boost::shared_ptr<CFile> getRelFile(void) const ;
62         
63         const date::CDuration & getFreqOperation(void) const;
64         const date::CDuration & getFreqWrite(void) const;
65
66         boost::shared_ptr<date::CDate> getLastWriteDate(void) const;
67         boost::shared_ptr<date::CDate> getLastOperationDate(void) const;
68
69         boost::shared_ptr<func::CFunctor> getFieldOperation(void) const;
70         
71         ARRAY(double, 1) getData(void) const;
72
73         const StdString & getBaseFieldId(void) const;
74
75         /// Mutateur ///
76         void setRelFile(const boost::shared_ptr<CFile> _file);
77
78         template <StdSize N>
79            inline bool updateData
80               (const date::CDate & currDate, const ARRAY(double, N) data);
81
82         bool updateDataServer
83               (const date::CDate & currDate, const std::deque<ARRAY(double, 1)> storedClient);
84
85      public :
86
87         /// Test ///
88         bool hasDirectFieldReference(void) const;
89
90         /// Traitements ///
91         void solveRefInheritance(void);
92         void solveGridReference(void);
93         void solveOperation(void);
94
95         virtual void fromBinary(StdIStream & is);
96
97         /// Destructeur ///
98         virtual ~CField(void);
99
100         /// Accesseurs statiques ///
101         static StdString GetName(void);
102         static StdString GetDefName(void);
103         
104         static ENodeType GetType(void);
105
106      private :
107
108         /// Propriétés privées ///
109         
110         std::vector<boost::shared_ptr<CField> > refObject;
111         boost::shared_ptr<CField> baseRefObject;
112         boost::shared_ptr<CGrid>  grid ;
113         boost::shared_ptr<CFile>  file;
114
115         date::CDuration freq_operation, freq_write;
116
117         boost::shared_ptr<date::CDate>    last_Write, last_operation;
118         boost::shared_ptr<func::CFunctor> foperation;
119         
120         ARRAY(double, 1) data;
121
122   }; // class CField
123
124   ///--------------------------------------------------------------
125
126   // Declare/Define CFieldGroup and CFieldDefinition
127   DECLARE_GROUP(CField);
128
129   } // namespace tree
130
131   ///-----------------------------------------------------------------
132
133   template <>
134      void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void);
135
136   ///-----------------------------------------------------------------
137} // namespace xmlioserver
138
139#include "grid.hpp"
140
141namespace xmlioserver {
142namespace tree {
143
144   template <StdSize N>
145      bool CField::updateData(const date::CDate & currDate, const ARRAY(double, N) data)
146   {
147      if ((*last_operation + freq_operation) >= currDate)
148      {
149         ARRAY_CREATE(input, double, 1, [0]);
150         input->resize(boost::extents[data->size()]);
151         this->grid->inputField(data, input);
152         (*this->foperation)(input);
153         *last_operation = currDate;
154      }
155     
156      if ((*last_Write + freq_write) >= currDate)
157      {
158         *last_Write = currDate;
159         return (true);
160      }
161      return (false);
162   };
163
164} // namespace tree
165} // namespace xmlioserver
166
167#endif // __XMLIO_CField__
Note: See TracBrowser for help on using the repository browser.