source: XMLIO_V2/dev/common/src/xmlio/node/field.hpp @ 219

Last change on this file since 219 was 219, checked in by hozdoba, 13 years ago

Préparation nouvelle arborescence

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      public :
64
65         const date::CDuration & getFreqOperation(void) const;
66         const date::CDuration & getFreqWrite(void) const;
67
68         boost::shared_ptr<date::CDate> getLastWriteDate(void) const;
69         boost::shared_ptr<date::CDate> getLastOperationDate(void) const;
70
71         boost::shared_ptr<func::CFunctor> getFieldOperation(void) const;
72         
73         ARRAY(double, 1) getData(void) const;
74
75         const StdString & getBaseFieldId(void) const;
76
77         /// Mutateur ///
78         void setRelFile(const boost::shared_ptr<CFile> _file);
79
80         template <StdSize N>
81            inline bool updateData
82               (const date::CDate & currDate, const ARRAY(double, N) data);
83
84         bool updateDataServer
85               (const date::CDate & currDate, const std::deque<ARRAY(double, 1)> storedClient);
86
87      public :
88
89         /// Test ///
90         bool hasDirectFieldReference(void) const;
91
92         /// Traitements ///
93         void solveRefInheritance(void);
94         void solveGridReference(void);
95         void solveOperation(void);
96
97         virtual void fromBinary(StdIStream & is);
98
99         /// Destructeur ///
100         virtual ~CField(void);
101
102         /// Accesseurs statiques ///
103         static StdString GetName(void);
104         static StdString GetDefName(void);
105         
106         static ENodeType GetType(void);
107
108      private :
109
110         /// Propriétés privées ///
111         
112         std::vector<boost::shared_ptr<CField> > refObject;
113         boost::shared_ptr<CField> baseRefObject;
114         boost::shared_ptr<CGrid>  grid ;
115         boost::shared_ptr<CFile>  file;
116
117         date::CDuration freq_operation, freq_write;
118
119         boost::shared_ptr<date::CDate>    last_Write, last_operation;
120         boost::shared_ptr<func::CFunctor> foperation;
121         
122         ARRAY(double, 1) data;
123
124   }; // class CField
125
126   ///--------------------------------------------------------------
127
128   // Declare/Define CFieldGroup and CFieldDefinition
129   DECLARE_GROUP(CField);
130
131   } // namespace tree
132
133   ///-----------------------------------------------------------------
134
135   template <>
136      void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void);
137
138   ///-----------------------------------------------------------------
139} // namespace xmlioserver
140
141#include "grid.hpp"
142
143namespace xmlioserver {
144namespace tree {
145
146   template <StdSize N>
147      bool CField::updateData(const date::CDate & currDate, const ARRAY(double, N) data)
148   {
149      if ((*last_operation + freq_operation) >= currDate)
150      {
151         ARRAY_CREATE(input, double, 1, [0]);
152         input->resize(boost::extents[data->size()]);
153         this->grid->inputField(data, input);
154         (*this->foperation)(input);
155         *last_operation = currDate;
156      }
157     
158      if ((*last_Write + freq_write) >= currDate)
159      {
160         *last_Write = currDate;
161         return (true);
162      }
163      return (false);
164   };
165
166} // namespace tree
167} // namespace xmlioserver
168
169#endif // __XMLIO_CField__
Note: See TracBrowser for help on using the repository browser.