GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FactoryItem.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004 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_FactoryItem
24 #define ADF_FactoryItem
25 
26 #ifndef ADF_ADFConfig
27 #include "ADFConfig.h"
28 #endif
29 #ifndef ADF_Version
30 #include "Version.h"
31 #endif
32 
33 #include <string>
34 #include <iostream>
35 
36 namespace ADF
37 {
38 
40 
53 {
54 private:
55  std::string fWhichFactory;
56  Short_t fWhichFactoryVersion;
57  std::string fWhichItem;
58  Version fWhichVersion;
59 
60 private:
62 
65  void * fPtrFactory;
66 
67 
68 public:
69  FactoryItem();
70  FactoryItem(const Char_t* factname,const Char_t *whichitem, Version itemversion);
71  FactoryItem(const Char_t* factname, Short_t factversion, const Char_t *whichitem, Version itemversion);
72  FactoryItem(const FactoryItem &);
73  virtual ~FactoryItem()
74  {;}
75 
76  const std::string &GetFactoryName() const
77  { return fWhichFactory; }
78  const std::string &GetItemName() const
79  { return fWhichItem; }
80 
82  Short_t GetFactoryVersion() const
83  { return fWhichFactoryVersion; }
85  void SetFactoryVersion(Short_t v)
86  { fWhichFactoryVersion = v; }
87 
89  { return fWhichVersion; }
91  void SetVersion(const Version v)
92  { fWhichVersion = v; }
93 
94  void *GetFactoryPtr() const
95  { return fPtrFactory; }
97  void SetFactoryPtr(void *ptr)
98  { fPtrFactory = ptr; }
99 
101  void SetItem(const Char_t *whichfactory, const Char_t *whichitem, Version itemversion, Short_t factversion = -1, void *ptr = 0x0);
102  void SetItem(const Char_t *whichfactory, Short_t factversion, const Char_t *whichitem, Version itemversion, void *ptr = 0x0);
103 
104  void SetFactoryName(const char *fname)
105  { fWhichFactory = fname; }
106 
107  void SetItemName(const char *iname)
108  { fWhichItem = iname; }
109 
111 
114  Bool_t operator == (const FactoryItem &) const;
115 
117 
121  Bool_t IsAVersion(const FactoryItem &) const;
122 
123  void Print() const;
124 };
125 
127 typedef Bool_t (*PF_FactoryItemChange)(const FactoryItem &, const FactoryItem &);
128 
130 inline Bool_t ChangeOfVersion(const FactoryItem &item_from, const FactoryItem &item_to)
131 {
132  return item_from.IsAVersion(item_to);
133 }
134 
136 inline Bool_t NoChange(const FactoryItem &item_from, const FactoryItem &item_to)
137  { return item_from == item_to; }
138 
140 inline Bool_t AllChange(const FactoryItem & /*item_from*/, const FactoryItem & /*item_to*/)
141  { return true; }
142 
143 } // namespace ADF
144 
145 // operator ta read/write in a std stream
146 namespace std {
147  std::ostream & operator << (std::ostream & os, const ADF::FactoryItem &item) ;
148  std::istream & operator >> (std::istream & is, ADF::FactoryItem &item);
149 }
150 
151 #endif
152 
153 
154 
155 
156 
std::istream & operator>>(std::istream &is, ADF::FactoryItem &item)
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 AllChange(const FactoryItem &, const FactoryItem &)
Any changes (factory,type,version) allowed.
Definition: FactoryItem.h:140
void SetFactoryVersion(Short_t v)
Change the factory version.
Definition: FactoryItem.h:85
void Print() const
std::ostream & operator<<(std::ostream &os, const ADF::FactoryItem &item)
Bool_t(* PF_FactoryItemChange)(const FactoryItem &, const FactoryItem &)
prototype function to control the evolution of a factory item.
Definition: FactoryItem.h:127
Bool_t NoChange(const FactoryItem &item_from, const FactoryItem &item_to)
No changes allowed.
Definition: FactoryItem.h:136
Bool_t IsAVersion(const FactoryItem &) const
Compare two items.
void SetFactoryName(const char *fname)
Definition: FactoryItem.h:104
void SetVersion(const Version v)
change
Definition: FactoryItem.h:91
header file for Version.cpp
Short_t GetFactoryVersion() const
Ask the factory version.
Definition: FactoryItem.h:82
Base class for version numbers.
Definition: Version.h:38
const std::string & GetFactoryName() const
Definition: FactoryItem.h:76
void SetItemName(const char *iname)
Definition: FactoryItem.h:107
void SetItem(const Char_t *whichfactory, const Char_t *whichitem, Version itemversion, Short_t factversion=-1, void *ptr=0x0)
to change an item
Definition: FactoryItem.cpp:84
to set informations about the ADF configuration
Version GetVersion() const
Definition: FactoryItem.h:88
virtual ~FactoryItem()
Definition: FactoryItem.h:73
void SetFactoryPtr(void *ptr)
change
Definition: FactoryItem.h:97
void * GetFactoryPtr() const
Definition: FactoryItem.h:94
const std::string & GetItemName() const
Definition: FactoryItem.h:78
Bool_t operator==(const FactoryItem &) const
Compare two items.
Definition: FactoryItem.cpp:89
Base class that described an item in a Factory.
Definition: FactoryItem.h:52