~ubuntu-branches/ubuntu/vivid/debtags/vivid-proposed

« back to all changes in this revision

Viewing changes to libapt-front/apt-front/cache/entity/relation.h

  • Committer: Bazaar Package Importer
  • Author(s): Enrico Zini
  • Date: 2006-03-18 20:31:47 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20060318203147-d9uzdeong5f5nk14
Tags: 1.5.5
* Added dumpavail command.
* Don't rebuild the database on install: apt-index-watcher does it instead.
  Closes: #357103.
* Compiles with g++ 4.1.  Closes: #357360.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/** -*- C++ -*-
2
 
    @file cache/entity/relation.h
3
 
    @author Peter Rockai <me@mornfall.net>
4
 
*/
5
 
 
6
 
#include <apt-front/cache/entity/entity.h>
7
 
#include <apt-front/cache/component/packages.h>
8
 
#include <stdexcept>
9
 
#include <string>
10
 
#include <vector>
11
 
 
12
 
#ifndef APTFRONT_CACHE_ENTITY_RELATION_H
13
 
#define APTFRONT_CACHE_ENTITY_RELATION_H
14
 
 
15
 
namespace aptFront {
16
 
namespace cache {
17
 
namespace entity {
18
 
 
19
 
/**
20
 
   @brief Iterate over relations of a given package with others.
21
 
 
22
 
   This is your interface to the package relationships stored within apt's
23
 
   cache. This includes dependencies, reverse dependencies, conflicts,
24
 
   reverse conflicts. You can get the relevant relation iterators using
25
 
   the relevant PackageIterator accessors.
26
 
*/
27
 
class Relation : public Implementation<Relation, Base> {
28
 
public:
29
 
    enum Type { Dependency, ReverseDependency, Conflict, ReverseConflict };
30
 
    Relation() {}
31
 
    Relation( const Entity &i ) {
32
 
        initFromBase( i.impl() );
33
 
    }
34
 
 
35
 
    /* Interface safety. */
36
 
    bool valid() const { // XXX
37
 
        return m_cache;
38
 
    }
39
 
 
40
 
    /* RelationIterator functionality. */
41
 
    bool operator==( const Relation &d ) const {
42
 
        return d.m_cache == m_cache;
43
 
    }
44
 
 
45
 
    bool operator<( const Relation &d ) const {
46
 
        return false; // grr
47
 
    }
48
 
 
49
 
    /**
50
 
       @brief Get a sensible name of the relation.
51
 
 
52
 
       This will give you a reasonably useful name of the relation's declaration.
53
 
       It does NOT include the type! For a given package/version/type combination,
54
 
       this should also be fairly unique. It roughly corresponds how apt-cache
55
 
       formats the Depends: et al fields when showing package details.
56
 
    */
57
 
    std::string name() const { return ""; };
58
 
 
59
 
    /**
60
 
       @brief Get list of possible targets for this relation.
61
 
 
62
 
       This method will return you a list of all VersionIterator's that are
63
 
       fit for satisfying this relation declaration. For depends, this means
64
 
       list of packages that would satisfy the dependency (you need to have
65
 
       only once of those installed to satisfy it!), for conflicts, this means
66
 
       list of all packages conflicting with owner of this relation (you
67
 
       need to uninstall all of those to be able to install owner!).
68
 
    */
69
 
    std::vector<Version> targetList() const;
70
 
 
71
 
    /// Get the type of this relation.
72
 
    Type type() const;
73
 
 
74
 
    /// Get the owner PackageIterator (that is, the one from which we were obtained).
75
 
    Package ownerPackage() const;
76
 
 
77
 
    /// Get the owner VersionIterator (that is the one from which we were obtained).
78
 
    Version ownerVersion() const;
79
 
 
80
 
    /**
81
 
       @brief Get a "straight" version of this RelationIterator.
82
 
       
83
 
       This will return a straight (as opposed to reverse) version of this
84
 
       very same iterator. If it was already straight, you will get a copy
85
 
       of it. If it was reverse, the straight variant will be looked up in the
86
 
       cache and returned.
87
 
    */
88
 
    Relation straight() const;
89
 
 
90
 
protected:
91
 
    // XXX data
92
 
};
93
 
 
94
 
}
95
 
}
96
 
}
97
 
#endif