~ubuntu-branches/ubuntu/edgy/libapt-front/edgy

« back to all changes in this revision

Viewing changes to apt-front/cache/component/debtags/serializer.h

  • Committer: Bazaar Package Importer
  • Author(s): Enrico Zini
  • Date: 2006-03-18 21:54:49 UTC
  • Revision ID: james.westby@ubuntu.com-20060318215449-yknailhahesrff8z
Tags: 0.3.9
* apt-index-watcher now runs another instance of itself to do the update.
  Closes: #357549.
* Builds with GCC 4.1.  Closes: #357555.
* Implemented package relationships in completeRecord()

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
#define APTFRONT_CACHE_COMPONENT_DEBTAGS_SERIALIZER_H
8
8
 
9
9
#include <apt-front/forward.h>
10
 
#include <apt-front/cache/cache.h>
 
10
#include <apt-front/cache/component/base.h>
11
11
#include <tagcoll/Serializer.h>
12
12
 
13
 
namespace Tagcoll
14
 
{
15
 
 
16
 
/**
17
 
 * Convert Packages to strings
18
 
 */
19
 
template<>
20
 
class Converter<aptFront::cache::entity::Package, std::string>
21
 
{
22
 
public:
23
 
        std::string operator()(const aptFront::cache::entity::Package& item);
24
 
        OpSet<std::string> operator()(const OpSet<aptFront::cache::entity::Package>& items);
25
 
};
26
 
 
27
 
/**
28
 
 * Convert strings to Packages
29
 
 */
30
 
template<>
31
 
class Converter<std::string, aptFront::cache::entity::Package>
32
 
{
33
 
protected:
34
 
        aptFront::cache::Cache* cache;
35
 
public:
36
 
        Converter(aptFront::cache::Cache* cache = 0) : cache(cache) {}
37
 
 
38
 
        void setOwnerCache( aptFront::cache::Cache *c ) { cache = c; }
39
 
 
40
 
        aptFront::cache::entity::Package operator()(const std::string& item);
41
 
        OpSet<aptFront::cache::entity::Package> operator()(const OpSet<std::string>& items);
 
13
namespace aptFront {
 
14
namespace cache {
 
15
namespace component {
 
16
namespace debtags {
 
17
 
 
18
/**
 
19
 * Convert Facets to ints
 
20
 */
 
21
class FacetIntConverter : public Implementation<FacetIntConverter>,
 
22
        public Tagcoll::Converter<aptFront::cache::entity::Facet, int>,
 
23
        public Tagcoll::Converter<int, aptFront::cache::entity::Facet>
 
24
{
 
25
        typedef aptFront::cache::entity::Facet Facet;
 
26
        typedef Tagcoll::OpSet<aptFront::cache::entity::Facet> FacetSet;
 
27
        typedef Tagcoll::OpSet<int> IntSet;
 
28
public:
 
29
        virtual int operator()(const aptFront::cache::entity::Facet& item) const;
 
30
        virtual aptFront::cache::entity::Facet operator()(const int& item) const;
 
31
 
 
32
        virtual IntSet operator()(const FacetSet& item) const
 
33
                { return Tagcoll::Converter<Facet, int>::operator()(item); }
 
34
        virtual FacetSet operator()(const IntSet& item) const
 
35
                { return Tagcoll::Converter<int, Facet>::operator()(item); }
 
36
 
 
37
        static std::string componentName();
42
38
};
43
39
 
44
40
/**
45
41
 * Convert Facets to strings
46
42
 */
47
 
template<>
48
 
class Converter<aptFront::cache::entity::Facet, std::string>
 
43
class FacetStringConverter : public Implementation<FacetStringConverter>,
 
44
        public Tagcoll::Converter<aptFront::cache::entity::Facet, std::string>,
 
45
        public Tagcoll::Converter<std::string, aptFront::cache::entity::Facet>
49
46
{
 
47
        typedef aptFront::cache::entity::Facet Facet;
 
48
        typedef Tagcoll::OpSet<aptFront::cache::entity::Facet> FacetSet;
 
49
        typedef Tagcoll::OpSet<std::string> StringSet;
50
50
public:
51
 
        std::string operator()(const aptFront::cache::entity::Facet& item);
52
 
        OpSet<std::string> operator()(const OpSet<aptFront::cache::entity::Facet>& items);
 
51
        virtual std::string operator()(const aptFront::cache::entity::Facet& item) const;
 
52
        virtual aptFront::cache::entity::Facet operator()(const std::string& item) const;
 
53
 
 
54
        virtual StringSet operator()(const FacetSet& item) const
 
55
                { return Tagcoll::Converter<Facet, std::string>::operator()(item); }
 
56
        virtual FacetSet operator()(const StringSet& item) const
 
57
                { return Tagcoll::Converter<std::string, Facet>::operator()(item); }
 
58
 
 
59
        static std::string componentName();
53
60
};
54
61
 
55
62
/**
56
 
 * Convert strings to Facets
 
63
 * Convert Tags to ints
57
64
 */
58
 
template<>
59
 
class Converter<std::string, aptFront::cache::entity::Facet>
 
65
class TagIntConverter : public Implementation<TagIntConverter>,
 
66
        public Tagcoll::Converter<aptFront::cache::entity::Tag, int>,
 
67
        public Tagcoll::Converter<int, aptFront::cache::entity::Tag>
60
68
{
61
 
protected:
62
 
        aptFront::cache::Cache* cache;
 
69
        typedef aptFront::cache::entity::Tag Tag;
 
70
        typedef Tagcoll::OpSet<aptFront::cache::entity::Tag> TagSet;
 
71
        typedef Tagcoll::OpSet<int> IntSet;
63
72
public:
64
 
        Converter(aptFront::cache::Cache* cache = 0) : cache(cache) {}
65
 
 
66
 
        void setOwnerCache( aptFront::cache::Cache *c ) { cache = c; }
67
 
 
68
 
        aptFront::cache::entity::Facet operator()(const std::string& item);
69
 
        OpSet<aptFront::cache::entity::Facet> operator()(const OpSet<std::string>& items);
 
73
        virtual int operator()(const aptFront::cache::entity::Tag& item) const;
 
74
        virtual aptFront::cache::entity::Tag operator()(const int& item) const;
 
75
 
 
76
        virtual IntSet operator()(const TagSet& item) const
 
77
                { return Tagcoll::Converter<Tag, int>::operator()(item); }
 
78
        virtual TagSet operator()(const IntSet& item) const
 
79
                { return Tagcoll::Converter<int, Tag>::operator()(item); }
 
80
 
 
81
        static std::string componentName();
70
82
};
71
83
 
72
 
 
73
84
/**
74
85
 * Convert Tags to strings
75
86
 */
76
 
template<>
77
 
class Converter<aptFront::cache::entity::Tag, std::string>
78
 
{
79
 
public:
80
 
        std::string operator()(const aptFront::cache::entity::Tag& item);
81
 
        OpSet<std::string> operator()(const OpSet<aptFront::cache::entity::Tag>& items);
82
 
};
83
 
 
84
 
/**
85
 
 * Convert strings to Tags
86
 
 */
87
 
template<>
88
 
class Converter<std::string, aptFront::cache::entity::Tag>
89
 
{
90
 
protected:
91
 
        aptFront::cache::Cache* cache;
92
 
public:
93
 
        Converter(aptFront::cache::Cache* cache = 0) : cache(cache) {}
94
 
 
95
 
        void setOwnerCache( aptFront::cache::Cache *c ) { cache = c; }
96
 
 
97
 
        aptFront::cache::entity::Tag operator()(const std::string& item);
98
 
        OpSet<aptFront::cache::entity::Tag> operator()(const OpSet<std::string>& items);
99
 
};
100
 
 
101
 
 
102
 
};
 
87
class TagStringConverter : public Implementation<TagStringConverter>,
 
88
        public Tagcoll::Converter<aptFront::cache::entity::Tag, std::string>,
 
89
        public Tagcoll::Converter<std::string, aptFront::cache::entity::Tag>
 
90
{
 
91
        typedef aptFront::cache::entity::Tag Tag;
 
92
        typedef Tagcoll::OpSet<aptFront::cache::entity::Tag> TagSet;
 
93
        typedef Tagcoll::OpSet<std::string> StringSet;
 
94
public:
 
95
        virtual std::string operator()(const Tag& item) const;
 
96
        virtual Tag operator()(const std::string& item) const;
 
97
 
 
98
        virtual StringSet operator()(const TagSet& item) const
 
99
                { return Tagcoll::Converter<Tag, std::string>::operator()(item); }
 
100
        virtual TagSet operator()(const StringSet& item) const
 
101
                { return Tagcoll::Converter<std::string, Tag>::operator()(item); }
 
102
 
 
103
        TagSet parseTagList(const std::string& str) const;
 
104
 
 
105
        static std::string componentName();
 
106
};
 
107
 
 
108
/**
 
109
 * Convert Packages to ints
 
110
 */
 
111
class PackageIntConverter : public Implementation<PackageIntConverter>,
 
112
        public Tagcoll::Converter<aptFront::cache::entity::Package, int>,
 
113
        public Tagcoll::Converter<int, aptFront::cache::entity::Package>
 
114
{
 
115
        typedef aptFront::cache::entity::Package Package;
 
116
        typedef Tagcoll::OpSet<aptFront::cache::entity::Package> PackageSet;
 
117
        typedef Tagcoll::OpSet<int> IntSet;
 
118
public:
 
119
        virtual int operator()(const Package& item) const;
 
120
        virtual Package operator()(const int& item) const;
 
121
 
 
122
        virtual IntSet operator()(const PackageSet& item) const
 
123
                { return Tagcoll::Converter<Package, int>::operator()(item); }
 
124
        virtual PackageSet operator()(const IntSet& item) const
 
125
                { return Tagcoll::Converter<int, Package>::operator()(item); }
 
126
 
 
127
        static std::string componentName();
 
128
};
 
129
 
 
130
/**
 
131
 * Convert Packages to strings
 
132
 */
 
133
class PackageStringConverter : public Implementation<PackageStringConverter>,
 
134
        public Tagcoll::Converter<aptFront::cache::entity::Package, std::string>,
 
135
        public Tagcoll::Converter<std::string, aptFront::cache::entity::Package>
 
136
{
 
137
        typedef aptFront::cache::entity::Package Package;
 
138
        typedef Tagcoll::OpSet<aptFront::cache::entity::Package> PackageSet;
 
139
        typedef Tagcoll::OpSet<std::string> StringSet;
 
140
public:
 
141
        virtual std::string operator()(const Package& item) const;
 
142
        virtual Package operator()(const std::string& item) const;
 
143
 
 
144
        virtual StringSet operator()(const PackageSet& item) const
 
145
                { return Tagcoll::Converter<Package, std::string>::operator()(item); }
 
146
        virtual PackageSet operator()(const StringSet& item) const
 
147
                { return Tagcoll::Converter<std::string, Package>::operator()(item); }
 
148
 
 
149
        static std::string componentName();
 
150
};
 
151
 
 
152
}
 
153
}
 
154
}
 
155
}
103
156
 
104
157
#endif