Zipios++
collcoll.h
Go to the documentation of this file.
1#ifndef COLLCOLL_H
2#define COLLCOLL_H
3
4#include "zipios++/zipios-config.h"
5
6#include <string>
7#include <vector>
8
9#include "zipios++/fcoll.h"
10
11namespace zipios {
12
13using std::string ;
14
27public:
33 static inline CollectionCollection &inst() ;
34
37 explicit CollectionCollection() ;
38
40 inline CollectionCollection( const CollectionCollection &src ) ;
41
43 inline const CollectionCollection &operator= ( const CollectionCollection &src ) ;
44
51 bool addCollection( const FileCollection &collection ) ;
52
62 bool addCollection( FileCollection *collection ) ;
63
64 virtual void close() ;
65
66 virtual ConstEntries entries() const ;
67
68 virtual ConstEntryPointer getEntry( const string &name,
69 MatchPath matchpath = MATCH ) const ;
70
71 virtual istream *getInputStream( const ConstEntryPointer &entry ) ;
72
73 virtual istream *getInputStream( const string &entry_name,
74 MatchPath matchpath = MATCH ) ;
75
78 virtual int size() const ;
79
80 virtual FileCollection *clone() const ;
81
82 virtual ~CollectionCollection() ;
83
84protected:
90 void getEntry( const string &name,
92 std::vector< FileCollection * >::const_iterator &it,
93 MatchPath matchpath = MATCH ) const ;
94
95 vector< FileCollection * > _collections ;
96private:
97 static CollectionCollection *_inst ;
98};
99
100
105
106
107//
108// Inline (member) functions
109//
110
112 if( _inst != 0 )
113 return *_inst ;
114 else
115 return *( _inst = new CollectionCollection ) ;
116}
117
119 : FileCollection( src )
120{
121 _collections.reserve( src._collections.size() ) ;
122 std::vector< FileCollection * >::const_iterator it ;
123 for ( it = src._collections.begin() ; it != src._collections.end() ; ++it )
124 _collections.push_back( (*it)->clone() ) ;
125}
126
127
130 this->FileCollection::operator=( src ) ;
131// FileCollection::=( static_cast< FileCollection >( src ) ) ;
132
133 if ( this != &src ) {
134 // Destroy current contents.
135 std::vector< FileCollection * >::const_iterator it ;
136 for ( it = _collections.begin() ; it != _collections.end() ; ++it )
137 delete *it ;
138 // Then copy src's content.
139 _collections.clear() ;
140 _collections.reserve( src._collections.size() ) ;
141 for ( it = src._collections.begin() ; it != src._collections.end() ; ++it )
142 _collections.push_back( (*it)->clone() ) ;
143 }
144 return *this ;
145}
146
147} // namespace
148
149
150
151#endif
152
157/*
158 Zipios++ - a small C++ library that provides easy access to .zip files.
159 Copyright (C) 2000 Thomas Søndergaard
160
161 This library is free software; you can redistribute it and/or
162 modify it under the terms of the GNU Lesser General Public
163 License as published by the Free Software Foundation; either
164 version 2 of the License, or (at your option) any later version.
165
166 This library is distributed in the hope that it will be useful,
167 but WITHOUT ANY WARRANTY; without even the implied warranty of
168 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
169 Lesser General Public License for more details.
170
171 You should have received a copy of the GNU Lesser General Public
172 License along with this library; if not, write to the Free Software
173 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
174*/
CollectionCollection is a FileCollection that consists of an arbitrary number of FileCollections.
Definition collcoll.h:26
virtual ConstEntries entries() const
Returns a vector of const pointers to the entries in the FileCollection.
Definition collcoll.cpp:46
virtual ConstEntryPointer getEntry(const string &name, MatchPath matchpath=MATCH) const
Returns a ConstEntryPointer to a FileEntry object for the entry with the specified name.
Definition collcoll.cpp:58
bool addCollection(const FileCollection &collection)
Adds a collection.
Definition collcoll.cpp:21
static CollectionCollection & inst()
This static method provides a singleton instance of a CollectionCollection.
Definition collcoll.h:111
virtual FileCollection * clone() const
Create a heap allocated clone of the object this method is called for.
Definition collcoll.cpp:108
virtual istream * getInputStream(const ConstEntryPointer &entry)
Returns a pointer to an opened istream for the specified FileEntry.
Definition collcoll.cpp:72
CollectionCollection()
Constructor.
Definition collcoll.cpp:16
virtual int size() const
Returns the number in entries in all collections kept by the CollectionCollection object.
Definition collcoll.cpp:98
virtual void close()
Closes the FileCollection.
Definition collcoll.cpp:41
const CollectionCollection & operator=(const CollectionCollection &src)
Copy assignment operator.
Definition collcoll.h:129
FileCollection is an abstract baseclass that represents a collection of files.
Definition fcoll.h:21
const FileCollection & operator=(const FileCollection &src)
Copy assignment operator.
Definition fcoll.h:125
SimpleSmartPointer is a simple reference counting smart pointer template.
Header file that defines FileCollection.
vector< EntryPointer > ConstEntries
ConstEntries is a vector of ConstEntryPointer's.
Definition fileentry.h:43