# HG changeset patch # User Chris Cannam # Date 1562077726 -3600 # Node ID 826e0cb77d8e40db3271774c14ed2e717e279eef # Parent 074b860a78281b72365a60b9fc81a27d70a046e9 Add isa diff -r 074b860a7828 -r 826e0cb77d8e base/ById.h --- a/base/ById.h Tue Jul 02 14:08:25 2019 +0100 +++ b/base/ById.h Tue Jul 02 15:28:46 2019 +0100 @@ -121,9 +121,15 @@ public: static void add(int, std::shared_ptr); static void release(int); - static std::shared_ptr get(int); + static std::shared_ptr get(int); template + static bool isa(int id) { + std::shared_ptr p = get(id); + return bool(std::dynamic_pointer_cast(p)); + } + + template static std::shared_ptr getAs(int id) { std::shared_ptr p = get(id); return std::dynamic_pointer_cast(p); @@ -154,6 +160,11 @@ } template + static bool isa(Id id) { + return AnyById::isa(id.untyped); + } + + template static std::shared_ptr getAs(Id id) { return AnyById::getAs(id.untyped); }