#include <resourcehelper.h>
Public Member Functions | ||||
| ResourceHelper () | ||||
| ~ResourceHelper () | ||||
| const std::string | GetResourcePath (const ResourceDescriptor &descriptor) const | |||
| Converts a resource descriptor into relative file path to the main file of the given resource. | ||||
| const ResourceTypeHandler * | GetHandlerForFile (const DataType &resourceType, const std::string &filePath) const | |||
| ||||
| void | GetHandlersForDataType (const DataType &resourceType, std::vector< const ResourceTypeHandler * > &toFill) const | |||
| ||||
| void | RegisterResourceTypeHander (ResourceTypeHandler &handler) | |||
| Registers a new type handler. | ||||
| void | IndexResources (dtUtil::tree< ResourceTreeNode > &tree) const | |||
| Indexes the resources for a project. | ||||
| const std::string | CreateResourceCategory (const std::string &category, const DataType &type, dtUtil::tree< ResourceTreeNode > *dataTypeTree, dtUtil::tree< ResourceTreeNode > *&categoryInTree) const | |||
| Creates a resource category. | ||||
| bool | RemoveResourceCategory (const std::string &category, const DataType &type, bool recursive, dtUtil::tree< ResourceTreeNode > *dataTypeTree) const | |||
| Removes a category. | ||||
| void | RemoveResource (const ResourceDescriptor &resource, dtUtil::tree< ResourceTreeNode > *resourceTree) const | |||
| Removes a resource and updates the tree. | ||||
| const ResourceDescriptor | AddResource (const std::string &newName, const std::string &pathToFile, const std::string &category, const DataType &type, dtUtil::tree< ResourceTreeNode > *dataTypeTree) const | |||
| Adds a new resource to the current project and updates the tree. | ||||
| void | RemoveResourceFromTree (dtUtil::tree< ResourceTreeNode > &resourceTree, const ResourceDescriptor &resource) const | |||
| Removes a resource from the tree. | ||||
| dtDAL::ResourceHelper::ResourceHelper | ( | ) |
| dtDAL::ResourceHelper::~ResourceHelper | ( | ) |
| const std::string dtDAL::ResourceHelper::GetResourcePath | ( | const ResourceDescriptor & | descriptor | ) | const |
Converts a resource descriptor into relative file path to the main file of the given resource.
It does not validate if the path is valid, nor does it have the context to do so.
| descriptor | the resource descriptor to convert. |
| const ResourceTypeHandler * dtDAL::ResourceHelper::GetHandlerForFile | ( | const DataType & | resourceType, | |
| const std::string & | filePath | |||
| ) | const |
| resourceType | the type of resource. |
The datatype passed in MUST be a resource type.
| filePath | the handler for this file name will be returned. This should specify a full path. |
| ExceptionEnum::ProjectResourceError | if the datatype is a primitive type, not a resource type. |
| void dtDAL::ResourceHelper::GetHandlersForDataType | ( | const DataType & | resourceType, | |
| std::vector< const ResourceTypeHandler * > & | toFill | |||
| ) | const |
| resourceType | the type of resource. |
The datatype passed in MUST be a resource type.
| toFill | the vector to fill with the handlers. |
| ExceptionEnum::ProjectResourceError | if the datatype is a primitive type, not a resource type. |
| void dtDAL::ResourceHelper::RegisterResourceTypeHander | ( | ResourceTypeHandler & | handler | ) |
Registers a new type handler.
The method will get the datatype and applicable filters from the handler itself.
| handler | The resource type handler to register. |
| ExceptionEnum::ProjectResourceError | if the datatype of the handler is a primitive type, not a resource type. |
| void dtDAL::ResourceHelper::IndexResources | ( | dtUtil::tree< ResourceTreeNode > & | tree | ) | const |
Indexes the resources for a project.
It will use the handlers to index all of the different types of resources. The current directory should be the top of the project when this is called.
| tree | the tree of resources to fill. |
| const std::string dtDAL::ResourceHelper::CreateResourceCategory | ( | const std::string & | category, | |
| const DataType & | type, | |||
| dtUtil::tree< ResourceTreeNode > * | dataTypeTree, | |||
| dtUtil::tree< ResourceTreeNode > *& | categoryInTree | |||
| ) | const |
Creates a resource category.
The current directory should be the project context when this is called.
| category | The category of the resource. | |
| type | the datatype of the category | |
| dataTypeTree | a pointer to the resource tree for the datatype, or null to ignore resource indexing. | |
| categoryInTree | a output parameter that will be the resource tree for the newly created category. This value is undefined if the dataTypeTree parameter is NULL. |
| bool dtDAL::ResourceHelper::RemoveResourceCategory | ( | const std::string & | category, | |
| const DataType & | type, | |||
| bool | recursive, | |||
| dtUtil::tree< ResourceTreeNode > * | dataTypeTree | |||
| ) | const |
Removes a category.
This method expects the current directory to be the root of the project context.
| category | The category to remove. | |
| type | The datatype the category is in. | |
| recursive | true to recursively delete the category and all subcategories and resources. | |
| dataTypeTree | a pointer to the resource tree for the datatype, or null to ignore resource indexing. |
| ExceptionEnum::ProjectIOException | if the could not complete because of some sort of IO exception. | |
| ExceptionEnum::ProjectResourceError | if the resource could not be removed for reasons other than file io. | |
| ExceptionEnum::ProjectFileNotFound | on rare occasion, this could possibly be thrown if the file contents are changed while the recusive delete is occuring. |
| void dtDAL::ResourceHelper::RemoveResource | ( | const ResourceDescriptor & | resource, | |
| dtUtil::tree< ResourceTreeNode > * | resourceTree | |||
| ) | const |
Removes a resource and updates the tree.
| resource | the resource descriptor of the resource to remove. | |
| resourceTree | the tree to update or NULL to ignore. |
| const ResourceDescriptor dtDAL::ResourceHelper::AddResource | ( | const std::string & | newName, | |
| const std::string & | pathToFile, | |||
| const std::string & | category, | |||
| const DataType & | type, | |||
| dtUtil::tree< ResourceTreeNode > * | dataTypeTree | |||
| ) | const |
Adds a new resource to the current project and updates the tree.
| newName | the new name of the resource. This must NOT have an extension on it. | |
| pathToFile | the path to the file or directory to import. | |
| category | the category for the new resource. | |
| type | the datatype of the resource. | |
| dataTypeTree | pointer to the tree for the dataType to update, or NULL to ignore |
| void dtDAL::ResourceHelper::RemoveResourceFromTree | ( | dtUtil::tree< ResourceTreeNode > & | resourceTree, | |
| const ResourceDescriptor & | resource | |||
| ) | const |
Removes a resource from the tree.
This is called by removeResource.
| resourceTree | the tree of resources. | |
| resource | the resource descriptor for the resource to remove. |