1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * Copyright (C) 2000-2002 Ximian, Inc.
4 * Copyright (C) 2005 SUSE Linux Products GmbH
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 #include <y2util/Ustring.h>
30 #include <zypp/solver/detail/Channel.h>
31 #include <zypp/solver/detail/DependencyPtr.h>
32 #include <zypp/solver/detail/OrDependencyPtr.h>
33 #include <zypp/solver/detail/Spec.h>
34 #include <zypp/solver/detail/XmlNode.h>
35 #include <zypp/ResObject.h>
37 /////////////////////////////////////////////////////////////////////////
39 { ///////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////
42 { /////////////////////////////////////////////////////////////////////
43 /////////////////////////////////////////////////////////////////////
45 { ///////////////////////////////////////////////////////////////////
47 ///////////////////////////////////////////////////////////////////
49 // CLASS NAME : Relation
51 * A dependency relation
60 Relation (int op) { _op = op; }
64 virtual ~Relation() {}
66 // ---------------------------------- I/O
68 static std::string toString ( const Relation & relation );
70 static std::string toWord ( const Relation & relation );
72 virtual std::ostream & dumpOn( std::ostream & str ) const;
74 friend std::ostream& operator<<( std::ostream & str, const Relation & relation );
76 std::string asString ( void ) const;
78 // ---------------------------------- consts
80 static const Relation & Invalid;
81 static const Relation & Any;
82 static const Relation & Equal;
83 static const Relation & NotEqual;
84 static const Relation & Less;
85 static const Relation & LessEqual;
86 static const Relation & Greater;
87 static const Relation & GreaterEqual;
88 static const Relation & None;
90 static const Relation & parse (const char *relation);
92 // ---------------------------------- accessors
94 int op (void) const { return _op; }
96 bool isEqual () const;
99 bool operator==( const Relation & rel ) const {
100 return (_op == rel.op());
104 bool operator!=( const Relation & rel ) const {
105 return !(*this == rel);
110 ///////////////////////////////////////////////////////////////////
112 typedef std::list <DependencyPtr> DependencyList;
113 typedef std::list <constDependencyPtr> CDependencyList;
115 ///////////////////////////////////////////////////////////////////
117 // CLASS NAME : Dependency
122 class Dependency : public Spec {
123 REP_BODY(Dependency);
127 constChannelPtr _channel;
133 Dependency (const std::string & name,
134 const Relation & relation,
135 const Resolvable::Kind & kind = ResTraits<zypp::Package>::kind,
136 constChannelPtr channel = NULL,
137 int epoch = Edition::noepoch,
138 const std::string & version = "",
139 const std::string & release = "",
140 const zypp::Arch & arch = zypp::Arch(),
142 bool pre_dep = false);
144 Dependency (const std::string & name,
145 const Relation & relation,
146 const Resolvable::Kind & kind = ResTraits<zypp::Package>::kind,
147 constChannelPtr channel = NULL,
148 const zypp::Edition & edition = zypp::Edition(),
150 bool pre_dep = false);
152 Dependency (OrDependencyPtr or_dep); //RCResItemDep *rc_dep_or_new_provide (RCDepOr *dor);
154 Dependency (constXmlNodePtr node); //RCResItemDep *rc_xml_node_to_resItem_dep (const xmlNode *node);
156 virtual ~Dependency();
158 // ---------------------------------- I/O
160 const xmlNodePtr asXmlNode (void) const; // xmlNode *rc_resItem_dep_to_xml_node (RCResItemDep *dep_item);
162 static std::string toString ( const Dependency & dep );
164 static std::string toString ( const CDependencyList & deplist );
166 virtual std::ostream & dumpOn( std::ostream & str ) const;
168 friend std::ostream& operator<<( std::ostream & str, const Dependency & dep);
170 std::string asString ( void ) const;
172 // ---------------------------------- accessors
174 const Relation & relation() const { return _relation; }
175 constChannelPtr channel (void) const { return _channel; }
177 bool orDep (void) const { return _or_dep; }
178 void setOrDep (bool or_dep) { _or_dep = or_dep; }
180 bool preDep (void) const { return _pre_dep; }
181 void setPreDep (bool pre_dep) { _pre_dep = pre_dep; }
183 // ---------------------------------- methods
185 DependencyPtr parseXml (constXmlNodePtr node);
186 bool verifyRelation (constDependencyPtr prov) const;
189 // xmlNode *rc_resItem_dep_or_slist_to_xml_node (RCResItemDepSList *dep);
191 ///////////////////////////////////////////////////////////////////
192 };// namespace detail
193 /////////////////////////////////////////////////////////////////////
194 /////////////////////////////////////////////////////////////////////
195 };// namespace solver
196 ///////////////////////////////////////////////////////////////////////
197 ///////////////////////////////////////////////////////////////////////
199 /////////////////////////////////////////////////////////////////////////
201 #endif // _Dependency_h