Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

LatticeNode.cxx

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Lattice
00004 // Module:      LatticeNode
00005 // 
00006 // Description: See Lattice.h and LatticeNode.h
00007 //
00008 // Implementation:
00009 //   Two classes: LatticeLeftNode & LatticeRightNode
00010 //   See the header files.
00011 //
00012 // Author:      Jon Thaler
00013 // Created:     Sat Apr  4 07:03:03 EST 1998
00014 // $Id: LatticeNode.cxx,v 1.3 2001/08/14 20:42:21 messier Exp $
00015 //
00016 //  Minos Revision History
00017 //  
00018 //  This file has been converted automatically from the corresponding CLEO
00019 //  Lattice code by Nick West on: 14/03/2000 08:38:07
00020 //  
00021 //  It is being used to explore the possibility that a modified Lattice
00022 //  can be used in MINOS.  The main changes are:-
00023 //  
00024 //      1)  The removal Lattice templates classes:-
00025 //  
00026 //           a)  LinkData is dummy
00027 //           b)  Left and Right ID types are void*
00028 //  
00029 //      2)  Conversion of CLEO types and includes to MINOS equivalents
00030 //          e.g.:-
00031 //  
00032 //           a)  DABoolean -> Bool_t
00033 //           b)  report    -> MSG
00034 
00035 //
00036 
00037 //
00038 //
00039 
00040 
00041 //----------------------+
00042 // system include files |
00043 //----------------------+
00044 #if defined(AMBIGUOUS_STRING_FUNCTIONS_BUG)
00045 #include <string>
00046 #endif             
00047 #include <iostream>
00048 
00049 #if defined(STL_TEMPLATE_DEFAULT_PARAMS_FIRST_BUG)
00050 #include <vector>
00051 #include <algorithm>
00052 #endif /* STL_TEMPLATE_DEFAULT_PARAMS_FIRST_BUG */
00053 
00054 //--------------------+
00055 // user include files |
00056 //--------------------+
00057 #include "Lattice/LatticeNode.h"
00058 
00059 //-------------+
00060 // STL classes |
00061 //-------------+
00062 #include <vector>
00063 #include <algorithm>
00064 
00065 //-------------------+
00066 // static definition |
00067 //-------------------+
00068 const char* const kLLLNString = "Lattice.LatticeLeftNode";
00069 const char* const kLLRNString = "Lattice.LatticeRightNode";
00070 
00071 //-----------------------------+
00072 // constructors and destructor |
00073 //-----------------------------+
00074 //------+
00075 // Left |
00076 //------+ 
00077 LatticeLeftNode::
00078 LatticeLeftNode(const LatticeDef::StoreType& data)
00079   : m_Links   (*new Links),
00080     m_VLeftID (*new VectorLeftID),
00081     m_VRightID(*new VectorRightID),
00082     m_ID      (data.identifier())
00083 {
00084 }
00085  
00086 LatticeLeftNode::
00087 LatticeLeftNode(LeftID id)
00088   : m_Links   (*new Links),
00089     m_VLeftID (*new VectorLeftID),
00090     m_VRightID(*new VectorRightID),
00091     m_ID      (id)
00092 {
00093 }
00094  
00095 LatticeLeftNode::
00096 ~LatticeLeftNode()
00097 {
00098   delete &m_Links;
00099   delete &m_VLeftID;
00100   delete &m_VRightID;
00101 }
00102 
00103 //-------+
00104 // Right |
00105 //-------+  
00106 LatticeRightNode::
00107 LatticeRightNode(const LatticeDef::StoreType& data)
00108   : m_Links   (*new Links),
00109     m_VRightID(*new VectorRightID),
00110     m_VLeftID (*new VectorLeftID),
00111     m_ID      (data.identifier())
00112 { 
00113 }
00114   
00115 LatticeRightNode::
00116 LatticeRightNode(RightID id)
00117   : m_Links   (*new Links),
00118     m_VRightID(*new VectorRightID),
00119     m_VLeftID (*new VectorLeftID),
00120     m_ID      (id)
00121 { 
00122 }
00123   
00124 LatticeRightNode::
00125 ~LatticeRightNode()
00126 { delete &m_Links;
00127   delete &m_VLeftID;
00128   delete &m_VRightID;
00129 }
00130 
00131 //--------+
00132 // show() |
00133 //--------+ 
00134 void
00135 LatticeLeftNode::
00136 show(ostream& os) const
00137 {
00138   os << " Left data ID "       << identifier()      << ":"
00139      << endl
00140      << "   has              " << links().size()    << " links,"
00141      << endl
00142      << "   connecting it to " << m_VRightID.size() << " right data: ";
00143 
00144   // Right data.
00145   typedef LatticeLeftNode::RightItr Ritr;
00146   Ritr i    = m_VRightID.begin();
00147   Ritr iEnd = m_VRightID.end();
00148   for ( ; i != iEnd; ++i)
00149   {
00150     os << " " << *i;
00151   }
00152   os << endl
00153      << "   and shared with  " << m_VLeftID.size() << " left data:";
00154 
00155   // Left data.
00156   typedef LatticeLeftNode::LeftItr Litr;
00157   Litr  j    = m_VLeftID.begin();
00158   Litr  jEnd = m_VLeftID.end();
00159   for ( ; j != jEnd; ++j)
00160   {
00161     os << " " << *j;
00162   }
00163   os << endl;
00164 }
00165   
00166 void
00167 LatticeRightNode::
00168 show(ostream& os) const
00169 {
00170   os << " Right data ID "      << identifier()     << ":"
00171      << endl
00172      << "   has              " << links().size()   << " links,"
00173      << endl
00174      << "   connecting it to " << m_VLeftID.size() << " left data: ";
00175 
00176   // Left data.
00177   typedef LatticeRightNode::LeftItr Litr;
00178   Litr m    = m_VLeftID.begin();
00179   Litr mEnd = m_VLeftID.end();
00180   for ( ; m != mEnd; ++m)
00181   {
00182     os << " " << *m;
00183   }
00184   os << endl
00185      << "   and shared with  " << m_VRightID.size() << " right data:";
00186   // Right data.
00187   typedef LatticeRightNode::RightItr Ritr;
00188   Ritr n    = m_VRightID.begin();
00189   Ritr nEnd = m_VRightID.end();
00190   for ( ; n != nEnd; ++n)
00191   {
00192     os << " " << *n;
00193   }
00194   os << endl;
00195 }
00196 
00197 //------------------+
00198 // member functions |
00199 //------------------+
00200 //------+
00201 // Left |
00202 //------+
00203 //--- links() ------------------------------------------------------------       
00204 const LatticeLeftNode::
00205 Links&
00206 LatticeLeftNode      ::
00207 links() const
00208 {
00209   return m_Links;
00210 }
00211 
00212 //--- isLinkedTo(id) ---------------------------------------------------- 
00213 Bool_t
00214 LatticeLeftNode::
00215 isLinkedTo(RightID id) const
00216 {
00217   return (find(m_VRightID.begin(),m_VRightID.end(),id) == m_VRightID.end()) ?
00218           0 : 1;
00219 }
00220 
00221 //--- sharesLinksWith(id) ----------------------------------------------- 
00222 Bool_t
00223 LatticeLeftNode::
00224 sharesLinksWith(LeftID id) const
00225 {
00226   return (find(m_VLeftID.begin(),m_VLeftID.end(),id) == m_VLeftID.end()) ?
00227           0 : 1;
00228 }
00229 
00230 //--- identifier() ------------------------------------------------------ 
00231 LatticeLeftNode::LeftID
00232 LatticeLeftNode::
00233 identifier() const
00234 {
00235   return m_ID;
00236 }
00237 
00238 //-------+
00239 // Right |
00240 //-------+
00241 //--- links() ------------------------------------------------------------        
00242 const LatticeRightNode::
00243 Links&
00244 LatticeRightNode      ::
00245 links() const
00246 {
00247   return m_Links;
00248 }
00249 
00250 //--- isLinkedTo(id) ----------------------------------------------------  
00251 Bool_t
00252 LatticeRightNode::
00253 isLinkedTo(LeftID id) const
00254 {
00255   return (find(m_VLeftID.begin(),m_VLeftID.end(),id) == m_VLeftID.end()) ?
00256           0 : 1;
00257 }
00258 
00259 //--- sharesLinksWith(id) -----------------------------------------------  
00260 Bool_t
00261 LatticeRightNode::
00262 sharesLinksWith(RightID id) const
00263 {
00264   return (find(m_VRightID.begin(),m_VRightID.end(),id) == m_VRightID.end()) ?
00265           0 : 1;
00266 }
00267 
00268 //--- identifier() ------------------------------------------------------  
00269 LatticeRightNode::RightID 
00270 LatticeRightNode::
00271 identifier() const
00272 {
00273   return m_ID;
00274 }

Generated on Mon Feb 15 11:06:50 2010 for loon by  doxygen 1.3.9.1