SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Member Functions | Protected Member Functions | List of all members
smtk::geometry::Resource Class Reference

An abstract base class for SMTK resources that provide geometry for themselves and/or their components. More...

#include <Resource.h>

Inheritance diagram for smtk::geometry::Resource:
[legend]
Collaboration diagram for smtk::geometry::Resource:
[legend]

Public Member Functions

 smtkTypeMacro (smtk::geometry::Resource)
 
 smtkSuperclassMacro (smtk::resource::DerivedFrom< Resource, smtk::resource::Resource >)
 
 smtkSharedFromThisMacro (smtk::resource::PersistentObject)
 
std::unique_ptr< Geometry > & geometry (const Backend &backend)
 Given a backend, return a provider of geometry for that backend. More...
 
std::unique_ptr< Geometry > & geometry ()
 Return the first geometry provider (for any backend). More...
 
void visitGeometry (std::function< void(std::unique_ptr< Geometry > &)> visitor)
 Visit all existing geometry providers for this resource. More...
 
 Resource (Resource &&)=default
 
- Public Member Functions inherited from smtk::resource::DerivedFrom< Resource, smtk::resource::Resource >
bool isOfType (const Resource::Index &index) const override
 given a resource index, return whether or not this resource is or is derived from the resource described by the index.
 
bool isOfType (const std::string &typeName) const override
 given a resource's unique name, return whether or not this resource is or is derived from the resource described by the name.
 
int numberOfGenerationsFromBase (const std::string &typeName) const override
 
 DerivedFrom (const DerivedFrom &)=delete
 
- Public Member Functions inherited from smtk::resource::Resource
 smtkTypeMacro (smtk::resource::Resource)
 
 smtkSuperclassMacro (smtk::resource::PersistentObject)
 
 smtkSharedFromThisMacro (smtk::resource::PersistentObject)
 
virtual Index index () const
 index is a compile-time intrinsic of the derived resource; as such, it cannot be set.
 
template<class ResourceType >
bool isOfType () const
 given a resource type, return whether or not this resource is or is derived from the resource described by the index.
 
const smtk::common::UUIDid () const override
 id and location are run-time intrinsics of the derived resource; we need to allow the user to reset these values.
 
const std::string & location () const
 
bool setId (const smtk::common::UUID &myID) override
 Assign an ID to this object (used by readers; not for arbitrary reuse). More...
 
bool setLocation (const std::string &location)
 
std::string name () const override
 Return the user-assigned name of the resource. More...
 
bool setName (const std::string &name)
 
bool isNameSet ()
 
virtual bool clean () const
 Indicate whether the resource is in sync with its location. More...
 
void setClean (bool state=true)
 
void setMarkedForRemoval (bool val)
 Mark the resource to indicate it is about to removed (meaning it is being removed from memory not necessarily for deletion)
 
virtual bool isMarkedForRemoval () const
 Return whether the object is marked for removal.
 
ManagerPtr manager () const
 Resources that are managed have a non-null pointer to their manager.
 
virtual ComponentPtr find (const smtk::common::UUID &compId) const =0
 Given a resource component's UUID, return the resource component.
 
virtual Componentcomponent (const smtk::common::UUID &compId) const
 Given a component's UUID, return a raw pointer to the component.
 
template<typename ComponentType >
ComponentType * componentAs (const smtk::common::UUID &uuid) const
 A templated version of component() that casts its result to a type. More...
 
virtual std::function< bool(const Component &)> queryOperation (const std::string &) const
 given a std::string describing a query, return a functor for performing the query (accepts component as input, returns true if the component satisfies the query parameters).
 
virtual void visit (std::function< void(const ComponentPtr &)> &v) const =0
 visit all components in a resource.
 
ComponentSet find (const std::string &queryString) const
 Given a a std::string describing a query, return a set of components that satisfy the query criteria.
 
ComponentSet filter (const std::string &queryString) const
 
template<typename Collection >
Collection findAs (const std::string &queryString) const
 given a a std::string describing a query and a type of container, return a set of components that satisfy both. More...
 
template<typename Collection >
Collection filterAs (const std::string &queryString) const
 
Linkslinks () override
 
const Linkslinks () const override
 
Propertiesproperties () override
 
const Propertiesproperties () const override
 
const Queriesqueries () const
 
Queriesqueries ()
 
Locklock (Key()) const
 classes that are granted permission to the key may retrieve the resource's lock.
 
LockType locked () const
 Anyone can query whether or not the resource is locked.
 
 Resource (Resource &&) noexcept
 
- Public Member Functions inherited from smtk::resource::PersistentObject
 smtkTypeMacroBase (smtk::resource::PersistentObject)
 
template<typename T >
T::Ptr as ()
 Attempt to cast this object to a subclass.
 
template<typename T >
T::ConstPtr as () const
 Attempt to cast this object to a subclass.
 

Protected Member Functions

 Resource (const smtk::common::UUID &myID, smtk::resource::ManagerPtr manager)
 
 Resource (const smtk::common::UUID &myID)
 
 Resource (smtk::resource::ManagerPtr manager=nullptr)
 
- Protected Member Functions inherited from smtk::resource::DerivedFrom< Resource, smtk::resource::Resource >
 DerivedFrom (T &&... all)
 Forward all constructor arguments to the parent class.
 
 DerivedFrom (DerivedFrom &&rhs) noexcept=default
 
- Protected Member Functions inherited from smtk::resource::Resource
 Resource (const smtk::common::UUID &, ManagerPtr manager=nullptr)
 
 Resource (ManagerPtr manager=nullptr)
 

Additional Inherited Members

- Public Types inherited from smtk::resource::DerivedFrom< Resource, smtk::resource::Resource >
typedef smtk::resource::Resource ParentResource
 
- Public Types inherited from smtk::resource::Resource
typedef std::size_t Index
 
typedef smtk::resource::Metadata Metadata
 
typedef detail::ResourceLinks Links
 
typedef detail::ResourceProperties Properties
 
typedef query::Queries Queries
 
- Static Public Attributes inherited from smtk::resource::DerivedFrom< Resource, smtk::resource::Resource >
static const Resource::Index type_index
 A static index for this resource type. More...
 
- Static Public Attributes inherited from smtk::resource::Resource
static const Resource::Index type_index = std::type_index(typeid(Resource)).hash_code()
 
- Protected Attributes inherited from smtk::resource::Resource
WeakManagerPtr m_manager
 

Detailed Description

An abstract base class for SMTK resources that provide geometry for themselves and/or their components.

Member Function Documentation

◆ geometry() [1/2]

std::unique_ptr< Geometry > & smtk::geometry::Resource::geometry ( )

Return the first geometry provider (for any backend).

This may return null if (a) neither the resource nor anything it contains is capable of providing geometry or (b) the application is not linked to a library that can provide data in a format acceptable to the backend.

Use this method when querying for the existence of geometry or for object bounds, since it terminates earlier than visitGeometry(). Note, however, that:

  1. It assumes geometry objects for multiple backends will provide geometry and bounds identically for the same set of persistent objects.
  2. It assumes that the resource has been added to a resource manager that has a geometry manager observing it and that some generator for this resource type and any backend was registered with the geometry manager before this resource was added to the resource manager. Otherwise, no geometry object will have been constructed and there is no way to obtain the geometry manager from the resource manager to attempt construction if iteration of existing Geometry objects fails.

◆ geometry() [2/2]

std::unique_ptr< Geometry > & smtk::geometry::Resource::geometry ( const Backend backend)

Given a backend, return a provider of geometry for that backend.

This may return null if (a) neither the resource nor anything it contains is capable of providing geometry or (b) the application is not linked to a library that can provide data in a format acceptable to the backend.

◆ visitGeometry()

void smtk::geometry::Resource::visitGeometry ( std::function< void(std::unique_ptr< Geometry > &)>  visitor)

Visit all existing geometry providers for this resource.

This will invoke the given visitor function on each provider. Typically, this is used to inform all providers when a given object's geometry has been modified, like so:

{c++}
geometry::Resource::Ptr rsrc;
PersistentObject::Ptr obj;
rsrc->visitGeometry(
[&obj](std::unique_ptr<Geometry>& provider)
{
provider->markModified(obj);
}
);

(Note: the pattern above is used by smtk::operation::MarkGeometry; you should use that class rather than directly copy the code above to mark geometry as modified.)


The documentation for this class was generated from the following files: