![]() |
|
|
Bdb packages | Design docs | Source docs | Guidelines | Recent releases |
|
Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Compound Members File Members /BdbCond/BdbCondContainerLink.cc
Go to the documentation of this file.00001 //----------------------------------------------------------------------------- 00002 // 00003 // File and Version Information: 00004 // $Id: BdbCondContainerLink.cc,v 1.2 2002/06/21 18:46:51 ryd Exp $ 00005 // 00006 // Description: 00007 // Class BdbCondContainerLink. This transient class is ment to provide 00008 // an interface for (interval container) link names. 00009 // 00010 // This interface may be used either to build the correct link name 00011 // from their components or, given existing link name, to extract 00012 // the components. 00013 // 00014 // The first way is used to create a new link, meanwhile the second one 00015 // is used to verify the correctness of already existing link and to break 00016 // one (the link) onto their components. 00017 // 00018 // Environment: 00019 // Software developed for the BaBar Detector at the SLAC B-Factory. 00020 // 00021 // Author List: 00022 // Igor A. Gaponenko Original Author 00023 // 00024 // Copyright Information: 00025 // Copyright (C) 1999 Lawrence Berkeley Laboratory 00026 // 00027 //----------------------------------------------------------------------------- 00028 00029 //----------------------- 00030 // This Class's Header -- 00031 //----------------------- 00032 00033 #include "BdbCond/BdbCondContainerLink.hh" 00034 00035 //------------- 00036 // C Headers -- 00037 //------------- 00038 00039 extern "C" { 00040 #include <string.h> 00041 } 00042 00043 //--------------- 00044 // C++ Headers -- 00045 //--------------- 00046 00047 #include "BbrStdUtils/Tokenize.hh" 00048 using namespace babar::String; 00049 #include "BbrStdUtils/String.hh" 00050 #include <string> 00051 using std::string; 00052 00053 // --------------------------------- 00054 // -- Collaborating Class Headers -- 00055 // --------------------------------- 00056 00057 #include "ErrLogger/ErrLog.hh" 00058 00059 00060 //----------------------------------------------------------------------- 00061 // Local Macros, Typedefs, Structures, Unions and Forward Declarations -- 00062 //----------------------------------------------------------------------- 00063 00064 static const char rscid[] = "$Id: BdbCondContainerLink.cc,v 1.2 2002/06/21 18:46:51 ryd Exp $"; 00065 00066 //---------------- 00067 // Constructors -- 00068 //---------------- 00069 00070 BdbCondContainerLink::BdbCondContainerLink( ) : 00071 _isValid(false) 00072 { 00073 } 00074 00075 BdbCondContainerLink::BdbCondContainerLink( const char* theLinkName ) : 00076 _isValid(false) 00077 { 00078 const char* errorString = "BdbCondContainerLink::BdbCondContainerLink() -- ERROR IN THE CONSTRUCTOR."; 00079 00080 // Simple verification. 00081 00082 if( theLinkName == (const char*) 0 ) { 00083 ErrMsg(error) << errorString << endl 00084 << " The NULL character was passes to the constructor instead of a link name." << endmsg; 00085 return; 00086 } 00087 _link = string( theLinkName ); 00088 00089 // Verify the contents of the link by extrcating and verifying its components. 00090 // 00091 // NOTE: It's being assumed that components are separated by a white space. 00092 00093 Tokenize theTokenizer( _link ); 00094 00095 _origin = theTokenizer( ); 00096 _detector = theTokenizer( ); 00097 _container = theTokenizer( ); 00098 00099 string thePad = theTokenizer( ); 00100 00101 if( _origin.empty( ) || _detector.empty( ) || _container.empty( ) || ( ! thePad.empty( ))) { 00102 ErrMsg(error) << errorString << endl 00103 << " The wrong link name was passed to the constructor." << endl 00104 << " This name must have the following three components separated" << endl 00105 << " by spaces: <origin>_<detector>_<container>" << endmsg; 00106 return; 00107 } 00108 if( 3 != strlen( _detector.c_str() )) { 00109 ErrMsg(error) << errorString << endl 00110 << " The detector name extracted from the link is not 3 charcters" << endl 00111 << " in their length." << endmsg; 00112 return; 00113 } 00114 00115 // OK. Verification was OK. 00116 00117 _isValid = true; 00118 00119 } 00120 00121 BdbCondContainerLink::BdbCondContainerLink( const char* theOrigin, 00122 const char* theDetector, 00123 const char* theContainer ) : 00124 _isValid(false) 00125 { 00126 const char* errorString = "BdbCondContainerLink::BdbCondContainerLink() -- ERROR IN THE CONSTRUCTOR."; 00127 00128 // Simple verification. 00129 00130 if( theOrigin == (const char*) 0 ) { 00131 ErrMsg(error) << errorString << endl 00132 << " The NULL character was passes to the constructor instead of" << endl 00133 << " the container's origin." << endmsg; 00134 return; 00135 } 00136 if( theDetector == (const char*) 0 ) { 00137 ErrMsg(error) << errorString << endl 00138 << " The NULL character was passes to the constructor instead of" << endl 00139 << " a detector name." << endmsg; 00140 return; 00141 } 00142 if( theContainer == (const char*) 0 ) { 00143 ErrMsg(error) << errorString << endl 00144 << " The NULL character was passes to the constructor instead of" << endl 00145 << " a container name." << endmsg; 00146 return; 00147 } 00148 _origin = string( theOrigin ); 00149 _detector = string( theDetector ); 00150 _container = string( theContainer ); 00151 00152 _link = _origin + string( " " ) + _detector + string( " " ) + _container; 00153 00154 _isValid = true; 00155 } 00156 00157 BdbCondContainerLink::BdbCondContainerLink( const BdbCondContainerLink& theLink ) 00158 { 00159 _isValid = theLink._isValid; 00160 _origin = theLink._origin; 00161 _detector = theLink._detector; 00162 _container = theLink._container; 00163 _link = theLink._link; 00164 } 00165 00166 //------------- 00167 // Operators -- 00168 //------------- 00169 00170 BdbCondContainerLink& 00171 BdbCondContainerLink::operator=( const BdbCondContainerLink& theLink ) 00172 { 00173 _isValid = theLink._isValid; 00174 _origin = theLink._origin; 00175 _detector = theLink._detector; 00176 _container = theLink._container; 00177 _link = theLink._link; 00178 00179 return *this; 00180 } 00181 00182 //-------------- 00183 // Destructor -- 00184 //-------------- 00185 00186 BdbCondContainerLink::~BdbCondContainerLink( ) 00187 { 00188 } 00189 00190 ///////////////// 00191 // End Of File // 00192 /////////////////
BaBar Public Site | SLAC | News | Links | Who's Who | Contact Us
Page Owner: Jacek Becla
Last Update: October 04, 2002