Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph::RawResourceCollection Class Reference

#include <RawResourceCollection.h>

Inheritance diagram for ph::RawResourceCollection:
ph::ISdlReferenceGroup

Public Member Functions

std::shared_ptr< ISdlResourceget (std::string_view resourceName) const override
 Get a resource reference.
 
bool has (std::string_view resourceName) const override
 Check the existence of a resource reference.
 
void add (std::shared_ptr< ISdlResource > resource, std::string_view resourceName)
 Add a resource.
 
std::shared_ptr< ISdlResourceremove (std::string_view resourceName)
 Remove a resource.
 
std::string rename (std::string_view resourceName, std::string_view newResourceName)
 Rename a resource. The new name must be unique within this collection. If newResourceName is not a unique name, a unique name is automatically determined (typically via makeResourceName()).
 
std::string makeResourceName (std::string_view intendedName)
 Create a resource name that is unique within this collection.
 
template<typename T >
std::vector< std::shared_ptr< T > > getAllOfType (std::vector< std::string > *out_resourceNames=nullptr) const
 Get all resources of type T. Different to its list<XXX>() variants, this method returns actual resources and allow modifications on them. The rest are similar to list<XXX>().
 
std::vector< std::shared_ptr< ISdlResource > > getAll (std::vector< std::string > *out_resourceNames=nullptr) const
 Get a list of all resources in the scene. See getAllOfType() for details on the method.
 
template<typename T >
std::vector< const T * > listAllOfType (std::vector< std::string > *out_resourceNames=nullptr) const
 Get a list of all resources of type T. Does not involve any change in ownership. Useful for operations that simply want to iterate over all resources of type T.
 
std::vector< const ISdlResource * > listAll (std::vector< std::string > *out_resourceNames=nullptr) const
 Get a list of all resources in the scene. See listAllOfType() for details on the method.
 
- Public Member Functions inherited from ph::ISdlReferenceGroup
 PH_DEFINE_INLINE_RULE_OF_5_MEMBERS_NO_DTOR (ISdlReferenceGroup)
 
virtual ~ISdlReferenceGroup ()=default
 
template<typename T >
std::shared_ptr< T > getTyped (std::string_view resourceName) const
 Get a resource reference of type T with name resourceName.
 
template<typename T >
bool hasTyped (std::string_view resourceName) const
 Check the existence of resource of type T.
 

Member Function Documentation

◆ add()

void ph::RawResourceCollection::add ( std::shared_ptr< ISdlResource > resource,
std::string_view resourceName )

Add a resource.

Parameters
resourceThe resource to be added.
resourceNameThe name given to the resource.
Exceptions
SdlLoadErrorIf input data is incomplete, e.g., being empty/null.

◆ get()

std::shared_ptr< ISdlResource > ph::RawResourceCollection::get ( std::string_view resourceName) const
inlineoverridevirtual

Get a resource reference.

Parameters
resourceNameThe name of the resource.
Returns
The resource requested. nullptr if not found.

Implements ph::ISdlReferenceGroup.

◆ getAll()

std::vector< std::shared_ptr< ISdlResource > > ph::RawResourceCollection::getAll ( std::vector< std::string > * out_resourceNames = nullptr) const

Get a list of all resources in the scene. See getAllOfType() for details on the method.

◆ getAllOfType()

template<typename T >
std::vector< std::shared_ptr< T > > ph::RawResourceCollection::getAllOfType ( std::vector< std::string > * out_resourceNames = nullptr) const
inline

Get all resources of type T. Different to its list<XXX>() variants, this method returns actual resources and allow modifications on them. The rest are similar to list<XXX>().

Parameters
out_resourceNamesStorage for resource names (1-to-1 mapping to the returned resources). Left unspecified (nullptr) if resource names are not required.
Returns
All resources of type T.

◆ has()

bool ph::RawResourceCollection::has ( std::string_view resourceName) const
inlineoverridevirtual

Check the existence of a resource reference.

Parameters
resourceNameThe name of the resource.

Implements ph::ISdlReferenceGroup.

◆ listAll()

std::vector< const ISdlResource * > ph::RawResourceCollection::listAll ( std::vector< std::string > * out_resourceNames = nullptr) const

Get a list of all resources in the scene. See listAllOfType() for details on the method.

◆ listAllOfType()

template<typename T >
std::vector< const T * > ph::RawResourceCollection::listAllOfType ( std::vector< std::string > * out_resourceNames = nullptr) const
inline

Get a list of all resources of type T. Does not involve any change in ownership. Useful for operations that simply want to iterate over all resources of type T.

Parameters
out_resourceNamesStorage for resource names (1-to-1 mapping to the returned resources). Left unspecified (nullptr) if resource names are not required.
Returns
Pointer to all resources of type T. The pointers are const as the method act like a view to the contained resources.
Note
Changing the state of the scene may invalidate the returned resource pointers as well as the returned names.

◆ makeResourceName()

std::string ph::RawResourceCollection::makeResourceName ( std::string_view intendedName)

Create a resource name that is unique within this collection.

Parameters
intendedNameIf the name given is already unique, then it will be used; otherwise, the name will be changed such that the resulting name is unique.

◆ remove()

std::shared_ptr< ISdlResource > ph::RawResourceCollection::remove ( std::string_view resourceName)

Remove a resource.

Parameters
resourceNameThe name given to the resource.
Returns
The removed resource. Null if no resource named resourceName.

◆ rename()

std::string ph::RawResourceCollection::rename ( std::string_view resourceName,
std::string_view newResourceName )

Rename a resource. The new name must be unique within this collection. If newResourceName is not a unique name, a unique name is automatically determined (typically via makeResourceName()).

Parameters
resourceNameName of the resource to be renamed.
newResourceNameThe intended new resource name.
Returns
The new resource name that the resource as renamed into.
Exceptions
SdlLoadErrorIf there is no resource named `resourceName`.

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