Cupt
package.hpp
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright (C) 2010 by Eugene V. Lyubimkin *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License *
6 * (version 3 or above) as published by the Free Software Foundation. *
7 * *
8 * This program is distributed in the hope that it will be useful, *
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11 * GNU General Public License for more details. *
12 * *
13 * You should have received a copy of the GNU GPL *
14 * along with this program; if not, write to the *
15 * Free Software Foundation, Inc., *
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA *
17 **************************************************************************/
18 #ifndef CUPT_CACHE_PACKAGE_SEEN
19 #define CUPT_CACHE_PACKAGE_SEEN
20 
22 
23 #include <cupt/cache/version.hpp>
24 
25 namespace cupt {
26 namespace internal {
27 
28 struct VersionParseParameters;
29 
30 template< typename VersionType >
31 class CUPT_API BasePackageIterator: public std::iterator< std::bidirectional_iterator_tag, const VersionType* >
32 {
33  friend class cache::Package;
34  friend class cache::BinaryPackage;
35  friend class cache::SourcePackage;
36 
37  typedef vector< unique_ptr< cache::Version > >::const_iterator UnderlyingIterator;
38 
39  UnderlyingIterator __ui;
40 
41  BasePackageIterator(UnderlyingIterator);
42  public:
43  typedef BasePackageIterator Self;
44 
45  Self& operator++();
46  const VersionType* operator*() const;
47  bool operator==(const Self&) const;
48  bool operator!=(const Self&) const;
49 };
50 
51 }
52 
53 namespace cache {
54 
56 class CUPT_API Package
57 {
58  vector< unique_ptr< Version > > __parsed_versions;
59 
60  CUPT_LOCAL void __merge_version(unique_ptr< Version >&&);
61 
62  Package(const Package&);
63  Package& operator=(const Package&);
64  protected:
66  const string* _binary_architecture;
67 
68  CUPT_LOCAL const vector< unique_ptr< Version > >& _get_versions() const;
69  CUPT_LOCAL virtual unique_ptr< Version > _parse_version(const internal::VersionParseParameters&) const = 0;
70  CUPT_LOCAL virtual bool _is_architecture_appropriate(const Version*) const = 0;
72  public:
74 
77  Package(const string* binaryArchitecture);
79  virtual ~Package();
81  CUPT_LOCAL void addEntry(const internal::VersionParseParameters&);
83 
85  vector< const Version* > getVersions() const;
87 
91  const Version* getSpecificVersion(const string& versionString) const;
92 
93  typedef internal::BasePackageIterator< Version > iterator;
94  iterator begin() const;
95  iterator end() const;
96 };
97 
98 }
99 }
100 
101 #endif
102 
common version information
Definition: version.hpp:39
a container for all versions of the same package name
Definition: package.hpp:56