1 /* 2 * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef DEPENDENCY_H 6 #define DEPENDENCY_H 7 8 9 #include <package/PackageResolvableOperator.h> 10 11 #include <Referenceable.h> 12 13 #include <util/DoublyLinkedList.h> 14 15 #include "String.h" 16 17 18 class DependencyFamily; 19 class Package; 20 class Resolvable; 21 class Version; 22 23 24 using BPackageKit::BPackageResolvableOperator; 25 26 27 class Dependency : public BReferenceable, 28 public DoublyLinkedListLinkImpl<Dependency> { 29 public: 30 Dependency(::Package* package); 31 virtual ~Dependency(); 32 33 status_t Init(const char* name); 34 void SetVersionRequirement( 35 BPackageResolvableOperator op, 36 Version* version); 37 // version is optional; object takes over 38 // ownership 39 40 ::Package* Package() const 41 { return fPackage; } 42 43 void SetFamily(DependencyFamily* family) 44 { fFamily = family; } 45 DependencyFamily* Family() const 46 { return fFamily; } 47 48 void SetResolvable(::Resolvable* resolvable) 49 { fResolvable = resolvable; } 50 ::Resolvable* Resolvable() const 51 { return fResolvable; } 52 bool ResolvableVersionMatches( 53 Version* resolvableVersion) const; 54 bool ResolvableCompatibleVersionMatches( 55 Version* resolvableVersion) const; 56 57 const String& Name() const { return fName; } 58 const String& FileName() const { return fFileName; } 59 60 private: 61 ::Package* fPackage; 62 DependencyFamily* fFamily; 63 ::Resolvable* fResolvable; 64 String fName; 65 String fFileName; 66 // fName with ':' replaced by '~' 67 Version* fVersion; 68 BPackageResolvableOperator fVersionOperator; 69 70 public: // conceptually package private 71 DoublyLinkedListLink<Dependency> fFamilyListLink; 72 DoublyLinkedListLink<Dependency> fResolvableListLink; 73 }; 74 75 76 typedef DoublyLinkedList<Dependency> DependencyList; 77 78 typedef DoublyLinkedList<Dependency, 79 DoublyLinkedListMemberGetLink<Dependency, 80 &Dependency::fFamilyListLink> > FamilyDependencyList; 81 82 typedef DoublyLinkedList<Dependency, 83 DoublyLinkedListMemberGetLink<Dependency, 84 &Dependency::fResolvableListLink> > ResolvableDependencyList; 85 86 87 #endif // DEPENDENCY_H 88