00001
00002 #include "IMPL/LCCollectionVec.h"
00003 #include "EVENT/LCIO.h"
00004 #include <iostream>
00005
00006
00007
00008 using namespace EVENT ;
00009
00010 namespace IMPL {
00011
00012
00013
00014
00015
00016 LCCollectionVec::LCCollectionVec( const std::string& type ) :
00017 _typeName( type ),
00018 _flag(0){
00019
00020
00021
00022 }
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 void LCCollectionVec::setReadOnly(bool readOnly){
00042
00043 AccessChecked::setReadOnly(readOnly ) ;
00044
00045 LCObjectVec::iterator iter = begin() ;
00046 while( iter != end() ){
00047 AccessChecked* element = dynamic_cast<AccessChecked*>(*iter++) ;
00048 if(element){
00049 element->setReadOnly( readOnly ) ;
00050 }
00051 }
00052 }
00053
00054 LCCollectionVec::~LCCollectionVec() {
00055
00056 if( ! isSubset() ){
00057
00058 LCObjectVec::const_iterator iter = begin() ;
00059
00060
00061
00062
00063 while( iter != end() ){
00064 delete *iter++ ;
00065 }
00066 }
00067 }
00068
00069
00070 int LCCollectionVec::getNumberOfElements() const{
00071 return size() ;
00072 }
00073
00074
00075 const std::string & LCCollectionVec::getTypeName() const{
00076 return _typeName ;
00077 }
00078
00079
00080
00081 EVENT::LCObject * LCCollectionVec::getElementAt(int index) const{
00082 return this->operator[](index) ;
00083 }
00084
00085 bool LCCollectionVec::isTransient() const {
00086 return (_flag & (1<<BITTransient) ) ;
00087 }
00088
00089 void LCCollectionVec::setTransient(bool val) {
00090 if(val) _flag |= (1<<BITTransient) ;
00091 else _flag &= ~(1<<BITTransient) ;
00092 }
00093
00094
00095 bool LCCollectionVec::isDefault() const {
00096 return (_flag & (1<<BITDefault) ) ;
00097 }
00098
00099 void LCCollectionVec::setDefault(bool val) {
00100 if(val) _flag |= (1<<BITDefault) ;
00101 else _flag &= ~(1<<BITDefault) ;
00102 }
00103
00104 bool LCCollectionVec::isSubset() const {
00105 return (_flag & (1<<BITSubset) ) ;
00106 }
00107
00108 void LCCollectionVec::setSubset(bool val) {
00109 if(val) _flag |= (1<<BITSubset) ;
00110 else _flag &= ~(1<<BITSubset) ;
00111 }
00112
00113
00114 int LCCollectionVec::getFlag() const{
00115 return _flag ;
00116 }
00117
00118
00119 void LCCollectionVec::setFlag(int flag){
00120 _flag = flag ;
00121 }
00122
00123
00124 void LCCollectionVec::addElement(EVENT::LCObject * obj) throw (ReadOnlyException){
00125
00126
00127
00128 checkAccess("LCCollectionVec::addElement") ;
00129 this->push_back( obj ) ;
00130 }
00131
00132 void LCCollectionVec::removeElementAt(int i) throw (EVENT::ReadOnlyException){
00133
00134
00135
00136 checkAccess("LCCollectionVec::removeElementAt") ;
00137 this->erase( begin() + i ) ;
00138
00139 }
00140
00141 }
00142