00001 #ifndef DATAUTILITIES_DYBARCHIVELIST_CPP 00002 #define DATAUTILITIES_DYBARCHIVELIST_CPP 00003 00004 // Include files 00005 #include "DataUtilities/DybArchiveList.h" 00006 00007 using namespace DayaBay; 00008 00009 DybArchiveList::DybArchiveList() 00010 : m_list(0) { 00011 } 00012 00014 DybArchiveList::DybArchiveList( const DybArchiveList& value ) 00015 : DataObject(*this), 00016 m_list(value.m_list) { 00017 } 00018 00020 DybArchiveList::~DybArchiveList() { 00021 clear(); 00022 } 00023 00025 const CLID& DybArchiveList::clID() const { 00026 return DybArchiveList::classID(); 00027 } 00028 00029 const CLID& DybArchiveList::classID() { 00030 // TODO - Fix this. 00031 static CLID clid = TemporalDataObject::classID() + CLID_ObjectList; 00032 return clid; 00033 } 00034 00036 /* 00037 const DybArchiveList& DybArchiveList::operator=(const DybArchiveList &right) { 00038 this->processingVersion = right.m_processingVersion; 00039 this->detectorDataObject = right.m_detectorDataObject; 00040 m_list = right.m_list; 00041 return *this; 00042 } 00043 */ 00044 00046 DybArchiveList::iterator DybArchiveList::begin () { 00047 return m_list.begin(); 00048 } 00049 00051 DybArchiveList::const_iterator DybArchiveList::begin () const { 00052 return m_list.begin(); 00053 } 00054 00056 DybArchiveList::iterator DybArchiveList::end () { 00057 return m_list.end(); 00058 } 00059 00061 DybArchiveList::const_iterator DybArchiveList::end () const { 00062 return m_list.end(); 00063 } 00064 00067 DybArchiveList::reverse_iterator DybArchiveList::rbegin () { 00068 return m_list.rbegin(); 00069 } 00070 00072 DybArchiveList::const_reverse_iterator DybArchiveList::rbegin () const { 00073 return m_list.rbegin(); 00074 } 00075 00077 DybArchiveList::reverse_iterator DybArchiveList::rend () { 00078 return m_list.rend(); 00079 } 00080 00082 DybArchiveList::const_reverse_iterator DybArchiveList::rend () const { 00083 return m_list.rend(); 00084 } 00085 00089 DybArchiveList::size_type DybArchiveList::size () const { 00090 return m_list.size(); 00091 } 00092 00094 long DybArchiveList::numberOfObjects() const { 00095 return m_list.size(); 00096 } 00097 00099 DybArchiveList::size_type DybArchiveList::max_size () const { 00100 return m_list.max_size(); 00101 } 00102 00104 bool DybArchiveList::empty () const { 00105 return m_list.empty(); 00106 } 00107 00109 DybArchiveList::reference DybArchiveList::front () { 00110 return m_list.front(); 00111 } 00112 00114 DybArchiveList::const_reference DybArchiveList::front () const { 00115 return m_list.front(); 00116 } 00117 00119 DybArchiveList::reference DybArchiveList::back () { 00120 return m_list.back(); 00121 } 00122 00124 DybArchiveList::const_reference DybArchiveList::back () const { 00125 return m_list.back(); 00126 } 00127 00129 void DybArchiveList::push_back( DybArchiveList::const_reference value ) { 00130 value->addRef(); 00131 m_list.push_back(value); 00132 } 00133 00135 void DybArchiveList::push_front( DybArchiveList::const_reference value ) { 00136 value->addRef(); 00137 m_list.push_front(value); 00138 } 00139 00142 void DybArchiveList::pop_back () { 00143 DybArchiveList::value_type position = m_list.back(); 00144 position->release(); 00145 m_list.pop_back(); 00146 } 00147 00149 DybArchiveList::iterator DybArchiveList::insert( DybArchiveList::iterator position, 00150 DybArchiveList::const_reference value ) { 00151 value->addRef(); 00152 DybArchiveList::iterator i = m_list.insert(position, value); 00153 return i; 00154 } 00155 00158 DybArchiveList::iterator DybArchiveList::erase( DybArchiveList::iterator position ) { 00159 (*position)->release(); 00160 // Removing from the container itself 00161 return m_list.erase(position); 00162 } 00163 00166 DybArchiveList::iterator DybArchiveList::erase( DybArchiveList::iterator first, 00167 DybArchiveList::iterator last ) { 00168 for( DybArchiveList::iterator iter = first; iter != last; iter++ ) { 00169 (*iter)->release(); 00170 } 00171 // Removing from the container itself 00172 return m_list.erase(first, last); 00173 } 00174 00176 void DybArchiveList::clear() { 00177 erase(begin(), end()); 00178 } 00179 00183 long DybArchiveList::index( const DataObject* obj ) const { 00184 long i = 0; 00185 DybArchiveList::const_iterator iter; 00186 for( iter = begin(); iter != end(); iter++ ) { 00187 if( obj == (*iter) ) { 00188 return i; 00189 } 00190 i++; 00191 } 00192 return -1; 00193 } 00194 00198 long DybArchiveList::index( const TemporalDataObject* obj ) const { 00199 long i = 0; 00200 DybArchiveList::const_iterator iter; 00201 for( iter = begin(); iter != end(); iter++ ) { 00202 if( obj == dynamic_cast<TemporalDataObject*>(*iter) ) { 00203 return i; 00204 } 00205 i++; 00206 } 00207 return -1; 00208 } 00209 00211 DataObject* DybArchiveList::dataObject( long dist ) const { 00212 long i = 0; 00213 DybArchiveList::const_iterator iter; 00214 for( iter = begin(); iter != end(); iter++ ) { 00215 if( dist == i ) { 00216 return *iter; 00217 } 00218 i++; 00219 } 00220 return 0; 00221 } 00222 00224 TemporalDataObject* DybArchiveList::temporalDataObject( long dist ) const { 00225 long i = 0; 00226 DybArchiveList::const_iterator iter; 00227 for( iter = begin(); iter != end(); iter++ ) { 00228 if( dist == i ) { 00229 return dynamic_cast<TemporalDataObject*>(*iter); 00230 } 00231 i++; 00232 } 00233 return 0; 00234 } 00235 00237 std::ostream& DybArchiveList::fillStream( std::ostream& s ) const { 00238 s << "class DybArchiveList : size = " 00239 << std::setw(12) 00240 << size() << "\n"; 00241 // Output the base class 00242 //ObjectContainerBase::fillStream(s); 00243 if ( 0 != size() ) { 00244 s << "\nContents of the STL list :"; 00245 long count = 0; 00246 DybArchiveList::const_iterator iter; 00247 for( iter = m_list.begin(); iter != m_list.end(); iter++, count++ ) { 00248 s << "\nIndex " 00249 << std::setw(12) 00250 << count 00251 << " of object of type "<< **iter; 00252 } 00253 } 00254 return s; 00255 } 00256 00257 #endif // DATAUTILITIES_DYBARCHIVELIST_CPP