diff --git a/src/proc/asset.hpp b/src/proc/asset.hpp index def4a02ee..80e5f2aa7 100644 --- a/src/proc/asset.hpp +++ b/src/proc/asset.hpp @@ -108,6 +108,8 @@ namespace asset { ID (HashVal id) : hash(id) {} ID (const KIND& asset) : hash(asset.getID()) {} operator HashVal() const { return hash; } + + static ID INVALID; }; class DB; @@ -303,53 +305,59 @@ namespace asset { - /* ====== ordering of Assets and Asset-Pointers ====== */ - - /** ordering of Assets is based on the ordering - * of Ident tuples, which are supposed to be unique. - * By using our customised lumiera::P as smart ptr, - * comparison on P ptrs will be automatically - * forwarded to the Asset comparison operators. - * @note version info is irrelevant */ - inline int - Asset::Ident::compare (Asset::Ident const& oi) const - { - int res; - if (0 != (res=category.compare (oi.category))) return res; - if (0 != (res=org.compare (oi.org))) return res; - return name.compare (oi.name); - } - - - /** promote subtype-ptr to PAsset, e.g. for comparing */ - template - inline const PcAsset - pAsset (shared_ptr const& subPtr) - { - return static_pointer_cast (subPtr); - } - - - /** type trait for detecting a shared-ptr-to-asset */ - template - struct is_pAsset : boost::false_type {}; - - template - struct is_pAsset > - : boost::is_base_of {}; - - - /** convenient for debugging */ - inline string str (PcAsset const& a) - { - if (a) - return string (*a.get()); - else - return "Asset(NULL)"; - } - - - + /* ====== ordering of Assets and Asset-Pointers ====== */ + + /** ordering of Assets is based on the ordering + * of Ident tuples, which are supposed to be unique. + * By using our customised lumiera::P as smart ptr, + * comparison on P ptrs will be automatically + * forwarded to the Asset comparison operators. + * @note version info is irrelevant */ + inline int + Asset::Ident::compare (Asset::Ident const& oi) const + { + int res; + if (0 != (res=category.compare (oi.category))) return res; + if (0 != (res=org.compare (oi.org))) return res; + return name.compare (oi.name); + } + + + /** promote subtype-ptr to PAsset, e.g. for comparing */ + template + inline const PcAsset + pAsset (shared_ptr const& subPtr) + { + return static_pointer_cast (subPtr); + } + + + /** type trait for detecting a shared-ptr-to-asset */ + template + struct is_pAsset : boost::false_type {}; + + template + struct is_pAsset > + : boost::is_base_of {}; + + + /** marker constant denoting a NIL asset */ + template + ID ID::INVALID = ID(0); + + + /** convenient for debugging */ + inline string str (PcAsset const& a) + { + if (a) + return string (*a.get()); + else + return "Asset(NULL)"; + } + + + + } // namespace asset diff --git a/src/proc/asset/pipe.hpp b/src/proc/asset/pipe.hpp index 922dec444..35c64664d 100644 --- a/src/proc/asset/pipe.hpp +++ b/src/proc/asset/pipe.hpp @@ -45,7 +45,13 @@ namespace asset { { public: ID (HashVal id); - ID (const Pipe&); + ID (Pipe const&); + ID (PPipe const&); + + /** allows a Pipe-ID to stand in for a full Pipe Asset + * @throw error::Invalid when there is no corresponding Pipe + */ + operator PPipe() const; }; @@ -95,8 +101,10 @@ namespace asset { // catch up with postponed definition of ID ctors... // - inline ID::ID(HashVal id) : ID (id) {}; - inline ID::ID(Pipe const& pipe) : ID (pipe.getID()) {}; + inline ID::ID(HashVal id) : ID (id) {}; + inline ID::ID(Pipe const& pipe) : ID (pipe.getID()) {}; + inline ID::ID(PPipe const& pipe) : ID (pipe->getID()) {}; + inline ID::operator PPipe() const { return Pipe::lookup(*this); }