SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
smtk::resource::Metadata Class Reference

Resources are registered to a resource manager at runtime with an instance of smtk::resource::Metadata. More...

#include <Metadata.h>

Public Types

typedef std::function< void(const Metadata &)> Visitor
 
typedef MetadataObserver Observer
 
typedef MetadataObservers Observers
 

Public Member Functions

 Metadata (const std::string &typeName, Resource::Index index, std::set< Resource::Index > parentIndices, std::function< ResourcePtr(const smtk::common::UUID &, const std::shared_ptr< smtk::common::Managers > &)> createFunctor=nullptr, std::function< ResourcePtr(const std::string &, const std::shared_ptr< smtk::common::Managers > &)> readFunctor=nullptr, std::function< bool(const ResourcePtr &, const std::shared_ptr< smtk::common::Managers > &)> writeFunctor=nullptr)
 
const std::string & typeName () const
 
const Resource::Index & index () const
 
bool isOfType (const Resource::Index &index) const
 

Public Attributes

std::function< ResourcePtr(const smtk::common::UUID &, const shared_ptr< smtk::common::Managers > &)> create
 A method that can be called to create a resource of the metadata's type. More...
 
std::function< ResourcePtr(const std::string &, const std::shared_ptr< smtk::common::Managers > &)> read
 A method that can be called to read a resource of the metadata's type from a file. More...
 
std::function< bool(const ResourcePtr &, const std::shared_ptr< smtk::common::Managers > &)> write
 A method that can be called to write a resource of the metadata's type. More...
 

Friends

class Manager
 The Manager is a singleton interface for registering available plugins to manager instances. More...
 

Detailed Description

Resources are registered to a resource manager at runtime with an instance of smtk::resource::Metadata.

Instances of this class must provide typeName, a unique (to the manager) string used to describe the resource within the manager. They may also provide functors for the creation and serialization/deserialization of the resource to/from disk (create, write and read, respectively). There are two variants of the read, write, and create methods: one takes a shared-pointer to an smtk::common::Managers instance and the other does not. The former is preferred.

Friends And Related Function Documentation

◆ Manager

friend class Manager
friend

The Manager is a singleton interface for registering available plugins to manager instances.

When a plugin is loaded, it creates a Client that adds itself to Manager's set of Client weak_ptrs. When a manager instance is passed into the Manager's "registerPluginsTo" method, each Client in the set that accepts a manager of this type constructs a Registry that tethers the scope of the manager's ability to use features from the plugin to the lifetime of the Registry object. Additionally, when a manager is passed into this class a register function is created that facilitates the registration of future plugins to the manager.

Member Data Documentation

◆ create

std::function<ResourcePtr(const smtk::common::UUID&, const shared_ptr<smtk::common::Managers>&)> smtk::resource::Metadata::create
Initial value:
=
[this](const smtk::common::UUID& uid, const shared_ptr<smtk::common::Managers>& managers) {
(void)uid;
(void)managers;
return ResourcePtr();
}

A method that can be called to create a resource of the metadata's type.

Provide a default method that returns a null pointer.

◆ read

std::function<ResourcePtr(const std::string&, const std::shared_ptr<smtk::common::Managers>&)> smtk::resource::Metadata::read
Initial value:
=
[this](const std::string& filename, const std::shared_ptr<smtk::common::Managers>& managers) {
(void)filename;
(void)managers;
return ResourcePtr();
}

A method that can be called to read a resource of the metadata's type from a file.

Provide a default that does nothing but return a null pointer.

◆ write

std::function<bool(const ResourcePtr&, const std::shared_ptr<smtk::common::Managers>&)> smtk::resource::Metadata::write
Initial value:
=
[this](const ResourcePtr& resource, const std::shared_ptr<smtk::common::Managers>& managers) {
(void)resource;
(void)managers;
return false;
}

A method that can be called to write a resource of the metadata's type.

Provide a default that does nothing and always returns false.


The documentation for this class was generated from the following file:
smtk::common::UUID
Definition: UUID.h:38
smtk::resource::ResourcePtr
smtk::shared_ptr< smtk::resource::Resource > ResourcePtr
Definition: PublicPointerDefs.h:295