1
#ifndef APTFRONT_CACHE_ENTITY_TAG_H
2
#define APTFRONT_CACHE_ENTITY_TAG_H
5
* Debtags facets and tags
9
* Copyright (C) 2005 Enrico Zini <enrico@debian.org>
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
#include <apt-front/cache/entity/entity.h>
28
#include <tagcoll/OpSet.h>
32
#include <debtags/fdecls.h>
38
namespace component { class Tags; }
45
* Representation of a facet.
47
* Tagcoll::Facet represents a Facet with all its informations. It is
48
* implemented via a reference-counted smart pointer, so it can be passed
49
* around freely and efficiently without worrying about memory management
52
* The class is normally instantiated using a Vocabulary:
54
* Facet facet = vocabulary.faceByNamet("made-of");
57
* Facets can contain a "false" value, in which case using any of their
58
* methonds produce a null-pointer dereference segfault. The "null" facets are
59
* useful as "none" return values:
62
* Facet facet = vocabulary.facetByName("made-of");
64
* throw ConsistencyCheckException("facet \"made-of\" has not been defined");
67
class Facet : public Implementation<Facet>
73
std::string shortDesc;
75
Data(const std::string& name)
77
Data(const std::string& name, const std::string& sd, const std::string& ld)
78
: name(name), shortDesc(sd), longDesc(ld) {}
84
Facet(Cache *c, int index) : index(index) {
89
Facet() : index(-1) {}
92
bool operator==(const Facet& f) const { return index == f.index; }
93
bool operator<(const Facet& f) const { return index < f.index; }
96
* Return true if the facet is valid
98
operator bool() const { return index != -1; }
99
bool valid() const { return index != -1; }
102
* Return the name of the facet
104
std::string name() const;
105
std::string name(const std::string& d) const;
108
* Return the short description of the facet
110
std::string shortDescription() const;
111
std::string shortDescription(const std::string& d) const;
114
* Return the long description of the facet
116
std::string longDescription() const;
117
std::string longDescription(const std::string& d) const;
120
* Return true if the facet has a tag with the given name (name, not fullname)
122
bool hasTag(const std::string& name) const;
125
* Return the list of tags in this facet
127
Tagcoll::OpSet<Tag> tags() const;
129
friend class entity::Tag;
130
friend class component::Tags;
134
* Representation of a tag.
136
* Tagcoll::Tag represents a Tag with all its informations. It is implemented
137
* via a reference-counted smart pointer, so it can be passed around freely and
138
* efficiently without worrying about memory management issues.
140
* The class is normally instantiated using a Vocabulary:
142
* Tag tag = vocabulary.tagByName("made-of::lang:c++");
145
* Tags can contain a "false" value, in which case using any of their
146
* methonds produce a null-pointer dereference segfault. The "null" tags are
147
* useful as "none" return values:
150
* Tag tag = vocabulary.tagByName("made-of");
152
* throw ConsistencyCheckException("tag \"mytag\" has not been defined");
155
class Tag : public Implementation<Tag>
162
std::string shortDesc;
163
std::string longDesc;
164
Data(int facet, const std::string& name)
165
: facet(facet), name(name) {}
166
Data(int facet, const std::string& name, const std::string& sd, const std::string& ld)
167
: facet(facet), name(name), shortDesc(sd), longDesc(ld) {}
172
Tag(Cache *c, int index) : index(index) {
180
bool operator==(const Tag& f) const { return index == f.index; }
181
bool operator<(const Tag& f) const { return index < f.index; }
183
operator bool() const { return index != -1; }
184
bool valid() const { return index != -1; }
189
* Return the name of the tag, without the facet:: prefix
191
std::string name() const;
192
std::string name(const std::string& d) const;
195
* Return the name of the tag, with the facet:: prefix
197
std::string fullname() const;
198
std::string fullname(const std::string& d) const;
201
* Return the short description of the tag
203
std::string shortDescription() const;
204
std::string shortDescription(const std::string& d) const;
207
* Return the long description of the tag
209
std::string longDescription() const;
210
std::string longDescription(const std::string& d) const;
212
friend class component::Tags;
219
// vim:set ts=3 sw=3: