00001 #ifndef COLLCOLL_H
00002 #define COLLCOLL_H
00003
00004 #include "zipios++/zipios-config.h"
00005
00006 #include <string>
00007 #include <vector>
00008
00009 #include "zipios++/fcoll.h"
00010
00011 namespace zipios {
00012
00013 using std::string ;
00014
00026 class CollectionCollection : public FileCollection {
00027 public:
00033 static inline CollectionCollection &inst() ;
00034
00037 explicit CollectionCollection() ;
00038
00040 inline CollectionCollection( const CollectionCollection &src ) ;
00041
00043 inline const CollectionCollection &operator= ( const CollectionCollection &src ) ;
00044
00051 bool addCollection( const FileCollection &collection ) ;
00052
00062 bool addCollection( FileCollection *collection ) ;
00063
00064 virtual void close() ;
00065
00066 virtual ConstEntries entries() const ;
00067
00068 virtual ConstEntryPointer getEntry( const string &name,
00069 MatchPath matchpath = MATCH ) const ;
00070
00071 virtual istream *getInputStream( const ConstEntryPointer &entry ) ;
00072
00073 virtual istream *getInputStream( const string &entry_name,
00074 MatchPath matchpath = MATCH ) ;
00075
00078 virtual int size() const ;
00079
00080 virtual FileCollection *clone() const ;
00081
00082 virtual ~CollectionCollection() ;
00083
00084 protected:
00090 void getEntry( const string &name,
00091 ConstEntryPointer &cep,
00092 std::vector< FileCollection * >::const_iterator &it,
00093 MatchPath matchpath = MATCH ) const ;
00094
00095 vector< FileCollection * > _collections ;
00096 private:
00097 static CollectionCollection *_inst ;
00098 };
00099
00100
00104 typedef CollectionCollection CColl ;
00105
00106
00107
00108
00109
00110
00111 CollectionCollection &CollectionCollection::inst() {
00112 if( _inst != 0 )
00113 return *_inst ;
00114 else
00115 return *( _inst = new CollectionCollection ) ;
00116 }
00117
00118 CollectionCollection::CollectionCollection( const CollectionCollection &src )
00119 : FileCollection( src )
00120 {
00121 _collections.reserve( src._collections.size() ) ;
00122 std::vector< FileCollection * >::const_iterator it ;
00123 for ( it = src._collections.begin() ; it != src._collections.end() ; ++it )
00124 _collections.push_back( (*it)->clone() ) ;
00125 }
00126
00127
00128 const CollectionCollection &
00129 CollectionCollection::operator= ( const CollectionCollection &src ) {
00130 this->FileCollection::operator=( src ) ;
00131
00132
00133 if ( this != &src ) {
00134
00135 std::vector< FileCollection * >::const_iterator it ;
00136 for ( it = _collections.begin() ; it != _collections.end() ; ++it )
00137 delete *it ;
00138
00139 _collections.clear() ;
00140 _collections.reserve( src._collections.size() ) ;
00141 for ( it = src._collections.begin() ; it != src._collections.end() ; ++it )
00142 _collections.push_back( (*it)->clone() ) ;
00143 }
00144 return *this ;
00145 }
00146
00147 }
00148
00149
00150
00151 #endif
00152
00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174