xref: /haiku/src/add-ons/kernel/file_systems/packagefs/resolvables/Dependency.h (revision b8ab901eeb0ce0eaa403182780268ffd69acf3c9)
11e7416d9SIngo Weinhold /*
21e7416d9SIngo Weinhold  * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
31e7416d9SIngo Weinhold  * Distributed under the terms of the MIT License.
41e7416d9SIngo Weinhold  */
51e7416d9SIngo Weinhold #ifndef DEPENDENCY_H
61e7416d9SIngo Weinhold #define DEPENDENCY_H
71e7416d9SIngo Weinhold 
81e7416d9SIngo Weinhold 
91e7416d9SIngo Weinhold #include <package/PackageResolvableOperator.h>
101e7416d9SIngo Weinhold 
111e7416d9SIngo Weinhold #include <Referenceable.h>
121e7416d9SIngo Weinhold 
131e7416d9SIngo Weinhold #include <util/DoublyLinkedList.h>
141e7416d9SIngo Weinhold 
15d07c930cSIngo Weinhold #include "String.h"
16d07c930cSIngo Weinhold 
171e7416d9SIngo Weinhold 
181e7416d9SIngo Weinhold class DependencyFamily;
191e7416d9SIngo Weinhold class Package;
201e7416d9SIngo Weinhold class Resolvable;
211e7416d9SIngo Weinhold class Version;
221e7416d9SIngo Weinhold 
231e7416d9SIngo Weinhold 
241e7416d9SIngo Weinhold using BPackageKit::BPackageResolvableOperator;
251e7416d9SIngo Weinhold 
261e7416d9SIngo Weinhold 
271e7416d9SIngo Weinhold class Dependency : public BReferenceable,
281e7416d9SIngo Weinhold 	public DoublyLinkedListLinkImpl<Dependency> {
291e7416d9SIngo Weinhold public:
301e7416d9SIngo Weinhold 								Dependency(::Package* package);
311e7416d9SIngo Weinhold 	virtual						~Dependency();
321e7416d9SIngo Weinhold 
331e7416d9SIngo Weinhold 			status_t			Init(const char* name);
341e7416d9SIngo Weinhold 			void				SetVersionRequirement(
351e7416d9SIngo Weinhold 									BPackageResolvableOperator op,
361e7416d9SIngo Weinhold 									Version* version);
371e7416d9SIngo Weinhold 									// version is optional; object takes over
381e7416d9SIngo Weinhold 									// ownership
391e7416d9SIngo Weinhold 
401e7416d9SIngo Weinhold 			::Package*			Package() const
411e7416d9SIngo Weinhold 									{ return fPackage; }
421e7416d9SIngo Weinhold 
431e7416d9SIngo Weinhold 			void				SetFamily(DependencyFamily* family)
441e7416d9SIngo Weinhold 									{ fFamily = family; }
451e7416d9SIngo Weinhold 			DependencyFamily*	Family() const
461e7416d9SIngo Weinhold 									{ return fFamily; }
471e7416d9SIngo Weinhold 
481e7416d9SIngo Weinhold 			void				SetResolvable(::Resolvable* resolvable)
491e7416d9SIngo Weinhold 									{ fResolvable = resolvable; }
501e7416d9SIngo Weinhold 			::Resolvable*		Resolvable() const
511e7416d9SIngo Weinhold 									{ return fResolvable; }
521e7416d9SIngo Weinhold 			bool				ResolvableVersionMatches(
531e7416d9SIngo Weinhold 									Version* resolvableVersion) const;
541e7416d9SIngo Weinhold 			bool				ResolvableCompatibleVersionMatches(
551e7416d9SIngo Weinhold 									Version* resolvableVersion) const;
561e7416d9SIngo Weinhold 
57d07c930cSIngo Weinhold 			const String&		Name() const		{ return fName; }
58*b8ab901eSIngo Weinhold 			const String&		FileName() const	{ return fFileName; }
591e7416d9SIngo Weinhold 
601e7416d9SIngo Weinhold private:
611e7416d9SIngo Weinhold 			::Package*			fPackage;
621e7416d9SIngo Weinhold 			DependencyFamily*	fFamily;
631e7416d9SIngo Weinhold 			::Resolvable*		fResolvable;
64d07c930cSIngo Weinhold 			String				fName;
65*b8ab901eSIngo Weinhold 			String				fFileName;
66*b8ab901eSIngo Weinhold 									// fName with ':' replaced by '~'
671e7416d9SIngo Weinhold 			Version*			fVersion;
681e7416d9SIngo Weinhold 			BPackageResolvableOperator fVersionOperator;
691e7416d9SIngo Weinhold 
701e7416d9SIngo Weinhold public:	// conceptually package private
711e7416d9SIngo Weinhold 			DoublyLinkedListLink<Dependency> fFamilyListLink;
721e7416d9SIngo Weinhold 			DoublyLinkedListLink<Dependency> fResolvableListLink;
731e7416d9SIngo Weinhold };
741e7416d9SIngo Weinhold 
751e7416d9SIngo Weinhold 
761e7416d9SIngo Weinhold typedef DoublyLinkedList<Dependency> DependencyList;
771e7416d9SIngo Weinhold 
781e7416d9SIngo Weinhold typedef DoublyLinkedList<Dependency,
791e7416d9SIngo Weinhold 	DoublyLinkedListMemberGetLink<Dependency,
801e7416d9SIngo Weinhold 		&Dependency::fFamilyListLink> > FamilyDependencyList;
811e7416d9SIngo Weinhold 
821e7416d9SIngo Weinhold typedef DoublyLinkedList<Dependency,
831e7416d9SIngo Weinhold 	DoublyLinkedListMemberGetLink<Dependency,
841e7416d9SIngo Weinhold 		&Dependency::fResolvableListLink> > ResolvableDependencyList;
851e7416d9SIngo Weinhold 
861e7416d9SIngo Weinhold 
871e7416d9SIngo Weinhold #endif	// DEPENDENCY_H
88