SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
A ResourceContainer is a container for a Project's Resources. More...
#include <ResourceContainer.h>
Public Types | |
typedef boost::multi_index_container< smtk::resource::ResourcePtr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< IdTag >, boost::multi_index::global_fun< const smtk::resource::ResourcePtr &, const smtk::common::UUID &, &smtk::resource::detail::id > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< IndexTag >, boost::multi_index::global_fun< const smtk::resource::ResourcePtr &, smtk::resource::Resource::Index, &smtk::resource::detail::index > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< NameTag >, boost::multi_index::global_fun< const smtk::resource::ResourcePtr &, std::string, &smtk::resource::detail::name > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< LocationTag >, boost::multi_index::global_fun< const smtk::resource::ResourcePtr &, const std::string &, &smtk::resource::detail::location > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< RoleTag >, boost::multi_index::global_fun< const smtk::resource::ResourcePtr &, const std::string &, &smtk::project::detail::role > > > > | Container |
A multi-index container for accessing resources. More... | |
using | iterator = typename Container::iterator |
using | const_iterator = typename Container::const_iterator |
Public Member Functions | |
bool | registerResource (const std::string &) |
Register a resource type according to its typename, type index or class type. | |
bool | registerResource (const smtk::resource::Resource::Index &) |
template<typename ResourceType > | |
bool | registerResource () |
bool | registerResources (const std::set< std::string > &) |
Register a set of resource types according to their typenames. | |
bool | unregisterResource (const std::string &) |
Unregister a resource type according to its typename, type index or class type. | |
bool | unregisterResource (const smtk::resource::Resource::Index &) |
template<typename ResourceType > | |
bool | unregisterResource () |
smtk::resource::ResourcePtr | get (const smtk::common::UUID &id) |
Returns the resource that relates to the given uuid. More... | |
smtk::resource::ConstResourcePtr | get (const smtk::common::UUID &id) const |
template<typename ResourceType > | |
smtk::shared_ptr< ResourceType > | get (const smtk::common::UUID &) |
template<typename ResourceType > | |
smtk::shared_ptr< const ResourceType > | get (const smtk::common::UUID &) const |
smtk::resource::ResourcePtr | get (const std::string &) |
Returns the resource that relates to the given url. More... | |
smtk::resource::ConstResourcePtr | get (const std::string &) const |
template<typename ResourceType > | |
smtk::shared_ptr< ResourceType > | get (const std::string &) |
template<typename ResourceType > | |
smtk::shared_ptr< const ResourceType > | get (const std::string &) const |
std::set< smtk::resource::ResourcePtr > | find (const std::string &) const |
Returns a set of resources that have a given typename, type index or class type. | |
std::set< smtk::resource::ResourcePtr > | find (const smtk::resource::Resource::Index &) const |
template<typename ResourceType > | |
std::set< smtk::shared_ptr< ResourceType > > | find () const |
bool | add (const smtk::resource::ResourcePtr &, const std::string &role=std::string()) |
Add a resource identified by its index or class type and by its role. More... | |
bool | add (const smtk::resource::Resource::Index &, const smtk::resource::ResourcePtr &, std::string role=std::string()) |
template<typename ResourceType > | |
bool | add (const smtk::shared_ptr< ResourceType > &, const std::string &role=std::string()) |
bool | remove (const smtk::resource::ResourcePtr &) |
Removes a resource from a given Project. More... | |
const std::set< std::string > & | types () const |
Return a whitelist of typenames of allowed resources. More... | |
std::set< std::string > & | types () |
std::shared_ptr< smtk::resource::Manager > | manager () const |
void | setManager (const std::weak_ptr< smtk::resource::Manager > &manager) |
const_iterator | begin () const |
iterator | begin () |
const_iterator | end () const |
iterator | end () |
bool | empty () const |
std::size_t | size () const |
void | clear () |
std::set< smtk::resource::ResourcePtr > | findByRole (const std::string &) |
std::set< smtk::resource::ConstResourcePtr > | findByRole (const std::string &) const |
template<typename ResourceType > | |
std::set< smtk::shared_ptr< ResourceType > > | findByRole (const std::string &) |
template<typename ResourceType > | |
std::set< smtk::shared_ptr< const ResourceType > > | findByRole (const std::string &) const |
Static Public Attributes | |
static constexpr const char *const | role_name = "project_role" |
A property key for accessing string-valued roles assigned to a resource held by a project. | |
Friends | |
class | Project |
A ResourceContainer is a container for a Project's Resources.
It holds a searchable collection of its Resources.
typedef boost::multi_index_container< smtk::resource::ResourcePtr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag<IdTag>, boost::multi_index::global_fun< const smtk::resource::ResourcePtr&, const smtk::common::UUID&, &smtk::resource::detail::id> >, boost::multi_index::ordered_non_unique< boost::multi_index::tag<IndexTag>, boost::multi_index::global_fun< const smtk::resource::ResourcePtr&, smtk::resource::Resource::Index, &smtk::resource::detail::index> >, boost::multi_index::ordered_non_unique< boost::multi_index::tag<NameTag>, boost::multi_index::global_fun< const smtk::resource::ResourcePtr&, std::string, &smtk::resource::detail::name> >, boost::multi_index::ordered_non_unique< boost::multi_index::tag<LocationTag>, boost::multi_index::global_fun< const smtk::resource::ResourcePtr&, const std::string&, &smtk::resource::detail::location> >, boost::multi_index::ordered_non_unique< boost::multi_index::tag<RoleTag>, boost::multi_index::global_fun< const smtk::resource::ResourcePtr&, const std::string&, &smtk::project::detail::role> > > > smtk::project::ResourceContainer::Container |
A multi-index container for accessing resources.
This class is primarily intended to be used in the implementation of smtk::resource::Manager only.
bool smtk::project::ResourceContainer::add | ( | const smtk::resource::ResourcePtr & | resource, |
const std::string & | role = std::string() |
||
) |
Add a resource identified by its index or class type and by its role.
Returns true if the resource was added or already is part of this manager.
std::set< smtk::resource::ResourcePtr > smtk::project::ResourceContainer::findByRole | ( | const std::string & | role | ) |
Returns the set of resources that relates to the given role. If no association exists this will return an empty set.
std::set< smtk::shared_ptr< ResourceType > > smtk::project::ResourceContainer::findByRole | ( | const std::string & | role | ) |
Returns the set of resources that relates to the given role. If no association exists this will return an empty set.
std::set< smtk::resource::ConstResourcePtr > smtk::project::ResourceContainer::findByRole | ( | const std::string & | role | ) | const |
Returns the set of resources that relates to the given role. If no association exists this will return an empty set.
std::set< smtk::shared_ptr< const ResourceType > > smtk::project::ResourceContainer::findByRole | ( | const std::string & | role | ) | const |
Returns the set of resources that relates to the given role. If no association exists this will return an empty set.
smtk::resource::ResourcePtr smtk::project::ResourceContainer::get | ( | const smtk::common::UUID & | id | ) |
Returns the resource that relates to the given uuid.
If no association exists this will return a null pointer.
smtk::resource::ResourcePtr smtk::project::ResourceContainer::get | ( | const std::string & | url | ) |
Returns the resource that relates to the given url.
If no association exists this will return a null pointer
bool smtk::project::ResourceContainer::remove | ( | const smtk::resource::ResourcePtr & | resource | ) |
|
inline |
Return a whitelist of typenames of allowed resources.
If Empty, all Resource types are allowed.