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 PACKAGE_LINK_DIRECTORY_H 61e7416d9SIngo Weinhold #define PACKAGE_LINK_DIRECTORY_H 71e7416d9SIngo Weinhold 81e7416d9SIngo Weinhold 91e7416d9SIngo Weinhold #include "Directory.h" 101e7416d9SIngo Weinhold #include "Package.h" 111e7416d9SIngo Weinhold #include "PackageLinkSymlink.h" 121e7416d9SIngo Weinhold 131e7416d9SIngo Weinhold 141e7416d9SIngo Weinhold class PackageLinksListener; 151e7416d9SIngo Weinhold 161e7416d9SIngo Weinhold 171e7416d9SIngo Weinhold class PackageLinkDirectory : public Directory { 181e7416d9SIngo Weinhold public: 191e7416d9SIngo Weinhold PackageLinkDirectory(); 201e7416d9SIngo Weinhold virtual ~PackageLinkDirectory(); 211e7416d9SIngo Weinhold 22*dfb09e12SAugustin Cavalier status_t Init(Package* package); 23*dfb09e12SAugustin Cavalier virtual status_t Init(const String& name); 241e7416d9SIngo Weinhold 251e7416d9SIngo Weinhold virtual timespec ModifiedTime() const; 261e7416d9SIngo Weinhold 27d0126238SIngo Weinhold virtual status_t OpenAttributeDirectory( 28d0126238SIngo Weinhold AttributeDirectoryCookie*& _cookie); 29d0126238SIngo Weinhold virtual status_t OpenAttribute(const StringKey& name, 30d0126238SIngo Weinhold int openMode, AttributeCookie*& _cookie); 31d0126238SIngo Weinhold 321e7416d9SIngo Weinhold void AddPackage(Package* package, 331e7416d9SIngo Weinhold PackageLinksListener* listener); 341e7416d9SIngo Weinhold void RemovePackage(Package* package, 351e7416d9SIngo Weinhold PackageLinksListener* listener); 361e7416d9SIngo Weinhold void UpdatePackageDependencies(Package* package, 371e7416d9SIngo Weinhold PackageLinksListener* listener); 381e7416d9SIngo Weinhold IsEmpty()391e7416d9SIngo Weinhold bool IsEmpty() const 401e7416d9SIngo Weinhold { return fPackages.IsEmpty(); } 411e7416d9SIngo Weinhold 421e7416d9SIngo Weinhold private: 431e7416d9SIngo Weinhold typedef PackageLinkSymlink Link; 441e7416d9SIngo Weinhold 451e7416d9SIngo Weinhold struct DependencyLink : public PackageLinkSymlink { DependencyLinkDependencyLink461e7416d9SIngo Weinhold DependencyLink(Package* package) 471e7416d9SIngo Weinhold : 481e7416d9SIngo Weinhold PackageLinkSymlink(package, TYPE_INSTALLATION_LOCATION) 491e7416d9SIngo Weinhold { 501e7416d9SIngo Weinhold } 511e7416d9SIngo Weinhold 521e7416d9SIngo Weinhold DoublyLinkedListLink<DependencyLink> fPackageLinkDirectoryLink; 531e7416d9SIngo Weinhold }; 541e7416d9SIngo Weinhold 551e7416d9SIngo Weinhold typedef DoublyLinkedList<DependencyLink, 561e7416d9SIngo Weinhold DoublyLinkedListMemberGetLink<DependencyLink, 571e7416d9SIngo Weinhold &DependencyLink::fPackageLinkDirectoryLink> > 581e7416d9SIngo Weinhold FamilyDependencyList; 591e7416d9SIngo Weinhold 601e7416d9SIngo Weinhold private: 611e7416d9SIngo Weinhold status_t _Update(PackageLinksListener* listener); 621e7416d9SIngo Weinhold status_t _UpdateDependencies( 631e7416d9SIngo Weinhold PackageLinksListener* listener); 641e7416d9SIngo Weinhold 651e7416d9SIngo Weinhold status_t _CreateOrUpdateLink(Link*& link, 661e7416d9SIngo Weinhold Package* package, Link::Type type, 67d07c930cSIngo Weinhold const String& name, 681e7416d9SIngo Weinhold PackageLinksListener* listener); 691e7416d9SIngo Weinhold void _RemoveLink(Link* link, 701e7416d9SIngo Weinhold PackageLinksListener* listener); 711e7416d9SIngo Weinhold 721e7416d9SIngo Weinhold private: 731e7416d9SIngo Weinhold timespec fModifiedTime; 741e7416d9SIngo Weinhold PackageList fPackages; 751e7416d9SIngo Weinhold Link* fSelfLink; 761e7416d9SIngo Weinhold Link* fSettingsLink; 771e7416d9SIngo Weinhold FamilyDependencyList fDependencyLinks; 781e7416d9SIngo Weinhold }; 791e7416d9SIngo Weinhold 801e7416d9SIngo Weinhold 811e7416d9SIngo Weinhold #endif // PACKAGE_LINK_DIRECTORY_H 82