00001 // -*- C++ -*- 00002 // 00003 // Package: Lattice 00004 // Module: LatticeLink 00005 // 00006 // Description: See LatticeLink.h and Lattice.h 00007 // 00008 // Implementation: 00009 // Data access: 00010 // linkData Returns a reference to the link data. 00011 // vLeftID " " " " vector of left IDs. 00012 // vRightID " " " " " right " 00013 // leftID " pointer to the one left ID (==0 is error). 00014 // leftID " " " " " right " " " " 00015 // 00016 // Author: Jon Thaler 00017 // Created: Sat Apr 4 07:03:03 EST 1998 00018 // $Id: LatticeLink.cxx,v 1.3 2001/08/14 20:42:21 messier Exp $ 00019 // 00020 // Minos Revision History 00021 // 00022 // This file has been converted automatically from the corresponding CLEO 00023 // Lattice code by Nick West on: 14/03/2000 08:38:07 00024 // 00025 // It is being used to explore the possibility that a modified Lattice 00026 // can be used in MINOS. The main changes are:- 00027 // 00028 // 1) The removal Lattice templates classes:- 00029 // 00030 // a) LinkData is dummy 00031 // b) Left and Right ID types are void* 00032 // 00033 // 2) Conversion of CLEO types and includes to MINOS equivalents 00034 // e.g.:- 00035 // 00036 // a) DABoolean -> Bool_t 00037 // b) report -> MSG 00038 #include "Lattice/LatticeNode.h" 00039 00040 // 00041 00042 // 00043 // 00044 00045 //-------------+ 00046 // Environment | 00047 //-------------+ 00048 00049 //----------------------+ 00050 // system include files | 00051 //----------------------+ 00052 #if defined(AMBIGUOUS_STRING_FUNCTIONS_BUG) 00053 #include <string> 00054 #endif 00055 #include <iostream> 00056 00057 #if defined(STL_TEMPLATE_DEFAULT_PARAMS_FIRST_BUG) 00058 #include <vector> 00059 #endif /* STL_TEMPLATE_DEFAULT_PARAMS_FIRST_BUG */ 00060 00061 //--------------------+ 00062 // user include files | 00063 //--------------------+ 00064 #include "Lattice/LatticeLink.h" 00065 00066 //-------------+ 00067 // STL classes | 00068 //-------------+ 00069 #include <vector> 00070 using namespace std; 00071 00072 //-------------------+ 00073 // static definition | 00074 //-------------------+ 00075 const char* const kLLLString = "Lattice.LatticeLink"; 00076 00077 //-----------------------------+ 00078 // Constructors and destructor | 00079 //-----------------------------+ 00080 //---------------------------------------------------+ 00081 // Given leftNode, rightNode, and linkData: | 00082 // * Copy the link data into this link | 00083 // * Construct a new LNodeTable and RNodeTable, | 00084 // and add the node IDs to the vectors. | 00085 // * LinkData must have default & copy constructors. | 00086 //---------------------------------------------------+ 00087 LatticeLink:: 00088 LatticeLink(LeftNode* lNode, RightNode* rNode) 00089 : m_LinkData(*new LinkData), 00090 m_VLeftID (*new VectorLeftID), 00091 m_VRightID(*new VectorRightID) 00092 { 00093 m_VLeftID .push_back(lNode->identifier()); 00094 m_VRightID.push_back(rNode->identifier()); 00095 } 00096 00097 LatticeLink:: 00098 LatticeLink(LeftNode* lNode, RightNode* rNode, const LinkData& linkData) 00099 : m_LinkData(*new LinkData(linkData)), 00100 m_VLeftID (*new VectorLeftID), 00101 m_VRightID(*new VectorRightID) 00102 { 00103 m_VLeftID .push_back(lNode->identifier()); 00104 m_VRightID.push_back(rNode->identifier()); 00105 } 00106 00107 LatticeLink:: 00108 ~LatticeLink() 00109 { 00110 delete &m_LinkData; 00111 delete &m_VLeftID; 00112 delete &m_VRightID; 00113 } 00114 00115 //-----------------------------------------------------------------+ 00116 // Data access: | 00117 // linkData Returns a reference to the link data. | 00118 // vLeftID " " " " vector of left IDs. | 00119 // vRightID " " " " " right " | 00120 // leftID " pointer to the one left ID (==0 is error). | 00121 // leftID " " " " " right " " " " | 00122 //-----------------------------------------------------------------+ 00123 LatticeDef::LinkData& 00124 LatticeLink:: 00125 linkData() 00126 { 00127 return m_LinkData; 00128 } 00129 00130 const LatticeDef::LinkData& 00131 LatticeLink:: 00132 linkData() const 00133 { 00134 return m_LinkData; 00135 } 00136 00137 const LatticeLink::VectorLeftID& 00138 LatticeLink ::vLeftID() const 00139 { 00140 return m_VLeftID; 00141 } 00142 00143 const LatticeLink::VectorRightID& 00144 LatticeLink ::vRightID() const 00145 { 00146 return m_VRightID; 00147 } 00148 00149 const LatticeLink::LeftID* 00150 LatticeLink ::leftID() const 00151 { 00152 return (1 != m_VLeftID.size()) ? 0 : &(m_VLeftID.front()); 00153 } 00154 00155 const LatticeLink::RightID* 00156 LatticeLink ::rightID() const 00157 { 00158 return (1 != m_VRightID.size()) ? 0 : &(m_VRightID.front()); 00159 } 00160 00161 //-----------------+ 00162 // Display: | 00163 // show(ostream&) | 00164 //-----------------+ 00165 void 00166 LatticeLink:: 00167 show(ostream& os) const 00168 { 00169 typedef LatticeLink::VectorLeftID 00170 VectorLeftID; 00171 typedef LatticeLink::VectorRightID 00172 VectorRightID; 00173 typedef VectorLeftID ::const_iterator LeftItr; 00174 typedef VectorRightID::const_iterator RightItr; 00175 00176 const VectorLeftID& ld = vLeftID(); 00177 const VectorRightID& rd = vRightID(); 00178 os << " Link " << ld.size() << " left data items to " 00179 << rd.size() << " right data items." <<endl 00180 << " Left IDs:"; 00181 for (LeftItr i = ld.begin(); i != ld.end(); ++i) 00182 { 00183 os << " " << *i; 00184 } 00185 os << endl << " Right IDs:"; 00186 for (RightItr j = rd.begin(); j != rd.end(); ++j) 00187 { 00188 os << " " << *j; 00189 } 00190 os << endl; 00191 }
1.3.9.1