GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DFAgent.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2010 by Olivier Stezowski *
3  * stezow(AT)ipnl.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #ifndef ADF_DFAgent
24 #define ADF_DFAgent
25 
26 #ifndef ADF_FactoryItem
27 #include "FactoryItem.h"
28 #endif
29 #ifndef ADF_ConfAgent
30 #include "ConfAgent.h"
31 #endif
32 #ifndef ADF_BaseBuffer
33 #include "BaseBuffer.h"
34 #endif
35 
36 #include <list>
37 #include <utility>
38 
39 namespace ADF
40 {
41 class KeyFactory;
42 class FrameFactory;
43 class Frame;
44 class ConfigurationFrame;
45 
47 
71 class DFAgent : public DotConf
72 {
73 private:
75  ConfAgent::EModel fModel;
76 private:
77 // Configurable part : value are modified in case of reconfiguration
79  BaseBuffer::EEndian fEndian;
81  FactoryItem fPrimaryKey;
83  std::pair <FactoryItem,FactoryItem> fAutoConf;
85  mutable std::list<std::pair <FactoryItem,FactoryItem> > fListOfFrames;
87  mutable std::list< FactoryItem > fListOfRequiredKeyFactories;
89  mutable std::list< FactoryItem > fListOfRequiredFrameFactories;
90 
91 private:
92 // Not completely configurable part : the list is not modified BUT the configuration of the factories is called. Be sure they are local in case of complex topology/multi-threading
94  std::list< KeyFactory * > fListOfKeyFactories;
96  std::list< FrameFactory * > fListOfFrameFactories;
97 
98 private:
100 
105  void LinkFactories(Bool_t global = true);
106 
107 protected:
109  virtual Bool_t ProcessLine(const std::string &);
110 
112  void AddKnownFrame(const FactoryItem &item_key, const FactoryItem &item_frame, const Char_t opt = '+') ;
113 
115  KeyFactory *GetKeyFactory(const FactoryItem &item) ;
118 
119 public:
121  DFAgent(const Char_t *rid, const Char_t *srid, Bool_t is_record = true, Bool_t global = true);
122  virtual ~DFAgent();
123 
125  const std::list<std::pair <FactoryItem,FactoryItem> > & GetListOfKnownFrames() const
126  {
127  return fListOfFrames;
128  }
129 
131 
134  Bool_t SetKnownKeyFactory(const FactoryItem &factory_item);
136 
139  Bool_t SetKnownFrameFactory(const FactoryItem &factory_item);
140 
142  Bool_t SetAsCompatibleKeyItem(FactoryItem &factory_item) const;
144  Bool_t SetAsCompatibleFrameItem(FactoryItem &factory_item) const;
146  Bool_t SetAsCompatibleItems(FactoryItem &factory_key_item, FactoryItem &factory_frame_item) const
147  { return SetAsCompatibleKeyItem(factory_key_item) && SetAsCompatibleFrameItem(factory_frame_item); }
148 
149  // endianness of the data flow
151  { return fEndian; }
153  { return fModel; }
154 
155  // change th e endian. it is applied to all the factories referenced in this agent
157  // io model
159  { fModel = model; }
160 
162  const FactoryItem &GetPrimaryKey() const;
163 
166  { return fAutoConf.first; }
168  { return fAutoConf.second; }
169 
171 
174  void SetPrimaryKey(const FactoryItem &item);
175 
177 
184  void AddKnownFrame(const Frame *frame, const Char_t opt = '+') ;
185 
187 
190  UShort_t IsAKnownFrame
192 
198 
200  virtual void Reset(const Char_t *opt = "");
201 
203  virtual Bool_t DoConfigure(std::istream &in, Bool_t allow_init)
204  { return DotConf::DoConfigure(in,allow_init); }
206  virtual Bool_t DoConfigure(std::ostream &);
207 };
208 
209 } // namespace ADF
210 
211 #endif
212 
213 
214 
215 
216 
217 
218 
219 
void SetEndian(BaseBuffer::EEndian)
Definition: DFAgent.cpp:319
const FactoryItem & GetPrimaryKey() const
Just to know if the size of the frame is coded on 2 bytes, 4 bytes ... or 8 bytes.
Definition: DFAgent.cpp:256
const std::list< std::pair< FactoryItem, FactoryItem > > & GetListOfKnownFrames() const
to just browse the list of known frame
Definition: DFAgent.h:125
virtual Bool_t ProcessLine(const std::string &)
decode an input line to configure/reconfigure this DFAgent
Definition: DFAgent.cpp:387
Base class for a FrameFactory.
Definition: FrameFactory.h:49
header file for FactoryItem.cpp
Base class for a Frame.
Definition: Frame.h:73
DotConf : Utility for class configuration from ascii file or Configuration frames.
Definition: DotConf.h:96
BaseBuffer::EEndian GetEndian() const
Definition: DFAgent.h:150
Bool_t ChangeOfVersion(const FactoryItem &item_from, const FactoryItem &item_to)
change from item_from to item_to is allowed if they differ only by the item version number ...
Definition: FactoryItem.h:130
Bool_t SetKnownFrameFactory(const FactoryItem &factory_item)
check if the factory is referenced by the agent.
Definition: DFAgent.cpp:175
Bool_t SetAsCompatibleKeyItem(FactoryItem &factory_item) const
Take the item and prepare it to be an item related to the is agent i.e. set the factory version # and...
Definition: DFAgent.cpp:216
KeyFactory * GetKeyFactory(const FactoryItem &item)
look in the DFAgent list if this factory exist and with a version # greater that the given one ...
Definition: DFAgent.cpp:106
virtual Bool_t DoConfigure(std::istream &in, Bool_t allow_init)
configure this from an input stream
Definition: DFAgent.h:203
DFAgent(const Char_t *rid, const Char_t *srid, Bool_t is_record=true, Bool_t global=true)
in case global is true, it keeps a list of pointers to the global factories otherwise asked for Clone...
Definition: DFAgent.cpp:42
Bool_t(* PF_FactoryItemChange)(const FactoryItem &, const FactoryItem &)
prototype function to control the evolution of a factory item.
Definition: FactoryItem.h:127
virtual void Reset(const Char_t *opt="")
Reset : all values are set to default.
Definition: DFAgent.cpp:303
UShort_t IsAKnownFrame(const FactoryItem &kit, const FactoryItem &fit, PF_FactoryItemChange kch=ChangeOfVersion, PF_FactoryItemChange fch=ChangeOfVersion) const
To know if a Frame is known by the Agent under the conditions given.
Definition: DFAgent.cpp:334
void AddKnownFrame(const FactoryItem &item_key, const FactoryItem &item_frame, const Char_t opt= '+')
internal use to avoid adding a definition of a Frame that cannot be allocated
Definition: DFAgent.cpp:266
void SetPrimaryKey(const FactoryItem &item)
to set the definition of the Keys for input
Definition: DFAgent.cpp:261
virtual ~DFAgent()
Definition: DFAgent.cpp:65
virtual Bool_t DoConfigure(std::istream &, Bool_t allow_init)
configure this from an input stream
Bool_t SetAsCompatibleItems(FactoryItem &factory_key_item, FactoryItem &factory_frame_item) const
change both item as the same time
Definition: DFAgent.h:146
FrameFactory * GetFrameFactory(const FactoryItem &item)
look in the DFAgent list if this factory exist and with a version # greater that the given one ...
Definition: DFAgent.cpp:120
FactoryItem WhichKnownKey(const FactoryItem &kit, const FactoryItem &fit, PF_FactoryItemChange kch=ChangeOfVersion, PF_FactoryItemChange fch=ChangeOfVersion) const
Definition: DFAgent.cpp:353
A DFAgent contains all the information concerning the structure of the data flow. ...
Definition: DFAgent.h:71
Bool_t SetKnownKeyFactory(const FactoryItem &factory_item)
check if the factory is referenced by the agent.
Definition: DFAgent.cpp:134
EModel
Model for FrameIO.
Definition: ConfAgent.h:69
ConfAgent::EModel GetModel() const
Definition: DFAgent.h:152
void SetModel(ConfAgent::EModel model)
Definition: DFAgent.h:158
header file for ConfAgent.cpp
const FactoryItem & GetAutoConfFrame() const
Definition: DFAgent.h:167
FactoryItem WhichKnownFrame(const FactoryItem &kit, const FactoryItem &fit, PF_FactoryItemChange kch=ChangeOfVersion, PF_FactoryItemChange fch=ChangeOfVersion) const
To get the exact definition of a key and a Frame.
Definition: DFAgent.cpp:370
const FactoryItem & GetAutoConfKey() const
To get the definition of the Key and Frame associated to a global reconfiguration.
Definition: DFAgent.h:165
Bool_t SetAsCompatibleFrameItem(FactoryItem &factory_item) const
Take the item and prepare it to be an item related to the is agent i.e. set the factory version # and...
Definition: DFAgent.cpp:236
Base Key factory.
Definition: KeyFactory.h:44
Base class that described an item in a Factory.
Definition: FactoryItem.h:52