GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FactoryItem.cpp
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 #include "FactoryItem.h"
25 #endif
26 
27 #include <stdio.h>
28 #include <iomanip>
29 
30 
31 /*
32 
33 */
34 
35 using namespace ADF;
36 
38  fWhichFactory(""),
39  fWhichFactoryVersion(-1),
40  fWhichItem(""),
41  fWhichVersion(0u,0u),
42  fPtrFactory(0x0)
43 {
44 
45 }
46 FactoryItem::FactoryItem(const Char_t *factname, const Char_t *whichitem, Version version) :
47  fWhichFactory(factname),
48  fWhichFactoryVersion(-1),
49  fWhichItem(whichitem),
50  fWhichVersion(version),
51  fPtrFactory(0x0)
52 {
53 
54 }
55 FactoryItem::FactoryItem(const Char_t *factname, Short_t factversion, const Char_t *whichitem, Version version) :
56  fWhichFactory(factname),
57  fWhichFactoryVersion(factversion),
58  fWhichItem(whichitem),
59  fWhichVersion(version),
60  fPtrFactory(0x0)
61 {
62 
63 }
64 
66 {
67  fWhichFactory = item.fWhichFactory.data();
68  fWhichFactoryVersion = item.fWhichFactoryVersion;
69  fWhichItem = item.fWhichItem.data();
70  fWhichVersion = item.fWhichVersion;
71  fPtrFactory = item.fPtrFactory;
72 }
73 
74 void FactoryItem::SetItem(const Char_t *whichfactory, Short_t factversion, const Char_t *whichitem, Version itemversion, void *ptr)
75 {
76  fWhichFactory = whichfactory;
77  fWhichFactoryVersion = factversion;
78  fWhichItem = whichitem;
79  fWhichVersion = itemversion;
80 
81  fPtrFactory = ptr;
82 }
83 
84 void FactoryItem::SetItem(const Char_t *whichfactory, const Char_t *whichitem, Version itemversion, Short_t factversion, void *ptr)
85 {
86  SetItem(whichfactory,factversion,whichitem,itemversion,ptr);
87 }
88 
89 Bool_t FactoryItem::operator == (const FactoryItem &item) const
90 {
91  Bool_t ok = true;
92 
93  ok = ok && ( fWhichFactory == item.fWhichFactory);
94  ok = ok && ( fWhichItem == item.fWhichItem);
95  ok = ok && ( fWhichVersion == item.fWhichVersion);
96 
97  return ok;
98 }
99 
100 Bool_t FactoryItem::IsAVersion(const FactoryItem &item) const
101 {
102  Bool_t ok = true;
103 
104  ok = ok && ( fWhichFactory == item.fWhichFactory);
105  ok = ok && ( fWhichItem == item.fWhichItem);
106 
107  return ok;
108 }
109 
110 void FactoryItem::Print() const
111 {
112  printf("Factory %s \n",fWhichFactory.data());
113  printf("Frame %s \n",fWhichItem.data());
114 }
115 
116 
117 
118 std::ostream & std::operator << (std::ostream & os, const ADF::FactoryItem &item)
119 {
120  os << " " << item.GetFactoryName()
121  << " " << item.GetFactoryVersion()
122  << " " << std::setw(20) << std::left << item.GetItemName() << std::right
123  << " " << item.GetVersion().GetMajor()
124  << " " << item.GetVersion().GetMinor();
125  return os;
126 }
127 
128 std::istream & std::operator >> (std::istream &is, ADF::FactoryItem &item)
129 {
130  std::string tmp1, tmp2; UInt_t ui1, ui2; Short_t s;
131 
132  is >> tmp1 >> s >> tmp2 >> ui1 >> ui2;
133  if ( is.good() )
134  item.SetItem(tmp1.data(),tmp2.data(),Version(ui1,ui2),s);
135 
136  return is;
137 }
138 
printf("******************************************************************** \n")
std::istream & operator>>(std::istream &is, ADF::FactoryItem &item)
header file for FactoryItem.cpp
void Print() const
std::ostream & operator<<(std::ostream &os, const ADF::FactoryItem &item)
Bool_t IsAVersion(const FactoryItem &) const
Compare two items.
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 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
UShort_t GetMinor() const
Definition: Version.h:61
Version GetVersion() const
Definition: FactoryItem.h:88
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
UShort_t GetMajor() const
Definition: Version.h:60