#include <project.h>
Public Member Functions | ||||
| void | CreateContext (const std::string &path) | |||
| Creates a new project context if it doesn't exist. | ||||
| bool | IsContextValid () const | |||
| ||||
| void | SetContext (const std::string &path, bool openReadOnly=false) | |||
| Assigns the context for the project. | ||||
| const std::string & | GetContext () const | |||
| ||||
| void | Refresh () | |||
| In the process of opening and using a project, lists of resources, maps, etc, are created This will clear or otherwise reload these cached lists so that any changes made to the project by hand will be picked up. | ||||
| const std::set< std::string > & | GetMapNames () | |||
| ||||
| Map & | GetMap (const std::string &name) | |||
| returns the map with the given name. | ||||
| Map & | OpenMapBackup (const std::string &name) | |||
| returns the last backup save of the map with the given name. | ||||
| Map & | LoadMapIntoScene (const std::string &name, dtCore::Scene &scene, bool addBillBoards=false, bool enablePaging=true) | |||
| Loads a map by name into an application. | ||||
| void | LoadMapIntoScene (Map &map, dtCore::Scene &scene, bool addBillBoards=false, bool enablePaging=true) | |||
| Loads a map into a scene. | ||||
| Map & | CreateMap (const std::string &name, const std::string &fileName) | |||
| Creates a new map and saves it. | ||||
| void | CloseMap (Map &map, bool unloadLibraries=false) | |||
| Closes the map passed in. | ||||
| void | CloseAllMaps (bool unloadLibraries=false) | |||
| Closes all open maps. | ||||
| void | DeleteMap (Map &map, bool unloadLibraries=false) | |||
| Deletes the given map. | ||||
| void | DeleteMap (const std::string &mapName, bool unloadLibraries=false) | |||
| Deletes the given map. | ||||
| void | SaveMap (Map &map, dtCore::Scene *pScene=NULL) | |||
| Saves the given map whether it has changed or not. | ||||
| void | SaveMapAs (Map &map, const std::string &newName, const std::string &newFileName, dtCore::Scene *pScene=NULL) | |||
| Saves the given map to a new file name and alters the open map object to point to the new file. | ||||
| void | SaveMapAs (const std::string &mapName, const std::string &newName, const std::string &newFileNam, dtCore::Scene *pScene=NULL) | |||
| Saves the given map to a new file name and alters the open map object to point to the new file. | ||||
| void | SaveMap (const std::string &mapName, dtCore::Scene *pScene=NULL) | |||
| Saves the given map whether it has changed or not. | ||||
| void | SaveMapBackup (Map &map) | |||
| Saves a new backup of the map. | ||||
| bool | HasBackup (Map &map) const | |||
| ||||
| bool | HasBackup (const std::string &mapName) const | |||
| ||||
| void | ClearBackup (Map &map) | |||
| Clears the backup save for a give map. | ||||
| void | ClearBackup (const std::string &mapName) | |||
| Clears the backup save for a given map. | ||||
| Map * | GetMapForActorProxy (const ActorProxy &proxy) | |||
| This will search all open maps until is finds the one that contains the given proxy. | ||||
| const Map * | GetMapForActorProxy (const ActorProxy &proxy) const | |||
| This will search all open maps until is finds the one that contains the given proxy. | ||||
| void | GetHandlersForDataType (const DataType &resourceType, std::vector< const ResourceTypeHandler * > &toFill) const | |||
| ||||
| void | RegisterResourceTypeHander (ResourceTypeHandler &handler) | |||
| Registers a new type handler. | ||||
| const std::string | GetResourcePath (const ResourceDescriptor &resource) const | |||
| This will take the resource descriptor object and return a path to the resource within the project. | ||||
| const ResourceDescriptor | AddResource (const std::string &newName, const std::string &pathToFile, const std::string &category, const DataType &type) | |||
| Adds a resource to the project by copying it into the project. | ||||
| void | RemoveResource (const ResourceDescriptor &resource) | |||
| Removes a resource from a project. | ||||
| void | CreateResourceCategory (const std::string &category, const DataType &type) | |||
| Creates a new resource category. | ||||
| bool | RemoveResourceCategory (const std::string &category, const DataType &type, bool recursive) | |||
| Removes a category. | ||||
| const dtUtil::tree < ResourceTreeNode > & | GetAllResources () const | |||
| ||||
| void | GetResourcesOfType (const DataType &type, dtUtil::tree< ResourceTreeNode > &toFill) const | |||
| ||||
| bool | IsArchive () const | |||
| ||||
| bool | IsReadOnly () const | |||
| ||||
| void | SetEditMode (bool pInStage) | |||
| This flag will alert actors whether or not there proxy is being loaded into STAGE as a note this should only be set from dtEditQt namespace potential refactor would be to ensure only dtEditQt could set it another implementation would be to have a project state which could control whether we are editing or not if need be we can add a getter for this. | ||||
| const bool | GetEditMode () const | |||
| Returns if Project is being executed from STAGE. | ||||
Static Public Member Functions | ||||
| static Project & | GetInstance () | |||
| ||||
Protected Member Functions | ||||
| virtual | ~Project () | |||
This represents the project directory structure and implements the methods to access and modify a project including the maps and resource content. This class is a singleton. Call the getInstance method for the single instance.
| dtDAL::Project::~Project | ( | ) | [protected, virtual] |
| static Project& dtDAL::Project::GetInstance | ( | void | ) | [inline, static] |
| void dtDAL::Project::CreateContext | ( | const std::string & | path | ) |
Creates a new project context if it doesn't exist.
| path | the full path to the new context directory |
| dtUtil::Exception | with ExceptionEnum::ProjectInvalidContext if the path specified is invalid. |
| bool dtDAL::Project::IsContextValid | ( | ) | const [inline] |
| void dtDAL::Project::SetContext | ( | const std::string & | path, | |
| bool | openReadOnly = false | |||
| ) |
Assigns the context for the project.
If it is not opened read only, the code will attempt to make the path into a project. It no longer creates a context if it does not exist.
| path | the file path of to the project | |
| openReadOnly | optional parameter that defaults to false. If true, the class will not attempt to modify the project directory. |
| ExceptionEnum::ProjectInvalidContext | if the path specified is invalid. |
| const std::string& dtDAL::Project::GetContext | ( | ) | const [inline] |
This will be empty if no valid context is set.
| void dtDAL::Project::Refresh | ( | ) |
In the process of opening and using a project, lists of resources, maps, etc, are created This will clear or otherwise reload these cached lists so that any changes made to the project by hand will be picked up.
| const std::set< std::string > & dtDAL::Project::GetMapNames | ( | ) |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. |
| Map & dtDAL::Project::GetMap | ( | const std::string & | name | ) |
returns the map with the given name.
| name | the name of the map as specified by the getMapNames() vector. |
| ExceptionEnum::MapLoadParsingError | if an error occurs reading the map file. | |
| FileExceptionEnum::FileNotFound | if the map does not exist. | |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. |
| Map & dtDAL::Project::OpenMapBackup | ( | const std::string & | name | ) |
returns the last backup save of the map with the given name.
| name | the name of the map as specified by the getMapNames() vector. |
| ExceptionEnum::MapLoadParsingError | if an error occurs reading the map file. | |
| FileExceptionEnum::FileNotFound | if a backup does not exist. | |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. |
| Map & dtDAL::Project::LoadMapIntoScene | ( | const std::string & | name, | |
| dtCore::Scene & | scene, | |||
| bool | addBillBoards = false, |
|||
| bool | enablePaging = true | |||
| ) |
Loads a map by name into an application.
If the map is already opened, the currently loaded map will be reused.
| name | The name of the map to load. | |
| scene | The application to add the proxy objects to. | |
| addBillBoards | pass true to add the billboards for any proxies that have the drawmode set to add the billboards. | |
| enablePaging | pass true to enable paging in the scene |
| ExceptionEnum::MapLoadParsingError | if an error occurs reading the map file. | |
| FileExceptionEnum::FileNotFound | if the map does not exist. | |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. |
| void dtDAL::Project::LoadMapIntoScene | ( | Map & | map, | |
| dtCore::Scene & | scene, | |||
| bool | addBillBoards = false, |
|||
| bool | enablePaging = true | |||
| ) |
Loads a map into a scene.
| map | The map to load into the scene | |
| scene | the scene to load the map into | |
| addBillBoards | pass true to add the billboards for any proxies that have the drawmode set to add the billboards. | |
| enablePaging | pass true to enable paging in the scene |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. |
| Map & dtDAL::Project::CreateMap | ( | const std::string & | name, | |
| const std::string & | fileName | |||
| ) |
Creates a new map and saves it.
| name | The name of the map. | |
| fileName | the name of the map file. |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. | |
| ExceptionEnum::ProjectReadOnly | if the project is read only. | |
| ExceptionEnum::ProjectException | if a map by that name or fileName already exists. | |
| ExceptionEnum::MapSaveError | if the new map could not be saved. |
| void dtDAL::Project::CloseMap | ( | Map & | map, | |
| bool | unloadLibraries = false | |||
| ) |
Closes the map passed in.
The map will likely be freed when this method exits.
| map | the map the close. | |
| unloadLibraries | unload all libraries not used by other open maps. This is dangerous. |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. |
| void dtDAL::Project::CloseAllMaps | ( | bool | unloadLibraries = false |
) |
Closes all open maps.
| unloadLibraries | unload all libraries not used by other open maps. This is dangerous. |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. |
| void dtDAL::Project::DeleteMap | ( | Map & | map, | |
| bool | unloadLibraries = false | |||
| ) |
Deletes the given map.
| map | the map the delete. | |
| unloadLibraries | unload all libraries not used by other open maps. This is dangerous. |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. | |
| ExceptionEnum::ProjectReadOnly | if the context is read only. |
| void dtDAL::Project::DeleteMap | ( | const std::string & | mapName, | |
| bool | unloadLibraries = false | |||
| ) |
Deletes the given map.
| mapName | the name of the map to delete. | |
| unloadLibraries | unload all libraries not used by other open maps. This is dangerous. |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. | |
| ExceptionEnum::ProjectReadOnly | if the context is read only. |
| void dtDAL::Project::SaveMap | ( | Map & | map, | |
| dtCore::Scene * | pScene = NULL | |||
| ) |
Saves the given map whether it has changed or not.
| map | the map to save. | |
| scene | map is being saved as, if no scene is present use NULL |
| ExceptionEnum::ProjectException | if you change the name to match another map. | |
| ExceptionEnum::ProjectInvalidContext | if the context is not set or the Map is not part of the project. | |
| ExceptionEnum::ProjectReadOnly | if the context is read only. | |
| ExceptionEnum::MapSaveError | if the new map could not be saved. |
| void dtDAL::Project::SaveMapAs | ( | Map & | map, | |
| const std::string & | newName, | |||
| const std::string & | newFileName, | |||
| dtCore::Scene * | pScene = NULL | |||
| ) |
Saves the given map to a new file name and alters the open map object to point to the new file.
There will then be no open copy of the old map file name.
| map | the map to save. | |
| scene | map is being saved as, if no scene is present use NULL | |
| newName | the new name of the map to save. | |
| newFileName | the new file name of the map to save. |
| ExceptionEnum::ProjectException | if a map by that name or fileName already exists. | |
| ExceptionEnum::ProjectInvalidContext | if the context is not set or the Map is not part of the project. | |
| ExceptionEnum::ProjectReadOnly | if the context is read only. | |
| ExceptionEnum::MapSaveError | if the new map could not be saved. |
| void dtDAL::Project::SaveMapAs | ( | const std::string & | mapName, | |
| const std::string & | newName, | |||
| const std::string & | newFileNam, | |||
| dtCore::Scene * | pScene = NULL | |||
| ) |
Saves the given map to a new file name and alters the open map object to point to the new file.
There will then be no open copy of the old map file name. Keep in mind that if the map name given is not loaded, this call will actually open the map before saving it.
| map | the current map name. | |
| scene | map is being saved as, if no scene is present use NULL | |
| newName | the new name of the map to save. | |
| newFileName | the new file name of the map to save. |
| ExceptionEnum::ProjectException | if a map by that name or fileName already exists. | |
| ExceptionEnum::ProjectInvalidContext | if the context is not set or the Map is not part of the project. | |
| ExceptionEnum::ProjectReadOnly | if the context is read only. | |
| ExceptionEnum::MapSaveError | if the new map could not be saved. |
| void dtDAL::Project::SaveMap | ( | const std::string & | mapName, | |
| dtCore::Scene * | pScene = NULL | |||
| ) |
Saves the given map whether it has changed or not.
If the map has not been loaded, but exists, this call is a NOOP.
| map | the map to save. | |
| scene | map is being saved as, if no scene is present use NULL |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. | |
| ExceptionEnum::ProjectReadOnly | if the context is read only. | |
| ExceptionEnum::MapSaveError | if the new map could not be saved. |
| void dtDAL::Project::SaveMapBackup | ( | Map & | map | ) |
Saves a new backup of the map.
| map | the map to save a backup of. |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. | |
| ExceptionEnum::ProjectReadOnly | if the context is read only. | |
| ExceptionEnum::MapSaveError | if the new map could not be saved. |
| bool dtDAL::Project::HasBackup | ( | Map & | map | ) | const |
| map | the map to get the backups count for. |
| bool dtDAL::Project::HasBackup | ( | const std::string & | mapName | ) | const |
| mapName | the name map to get the backups count for. |
| void dtDAL::Project::ClearBackup | ( | Map & | map | ) |
Clears the backup save for a give map.
| map | the map to clear the backups for. |
| void dtDAL::Project::ClearBackup | ( | const std::string & | mapName | ) |
Clears the backup save for a given map.
| mapName | the name of the map to clear the backups for. |
| Map * dtDAL::Project::GetMapForActorProxy | ( | const ActorProxy & | proxy | ) |
This will search all open maps until is finds the one that contains the given proxy.
| proxy | the proxy to search for. |
| const Map * dtDAL::Project::GetMapForActorProxy | ( | const ActorProxy & | proxy | ) | const |
This will search all open maps until is finds the one that contains the given proxy.
| proxy | the proxy to search for. |
| void dtDAL::Project::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::Project::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. |
| const std::string dtDAL::Project::GetResourcePath | ( | const ResourceDescriptor & | resource | ) | const |
This will take the resource descriptor object and return a path to the resource within the project.
The first time this is called, an index of the resources may need to be created internally to validate the string, so it may take some time to return.
| resource | The representation of a resource. |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. | |
| ExceptionEnum::ProjectResourceError | if the string representation is invalid. | |
| FileExceptionEnum::FileNotFound | if the file was not found. |
| const ResourceDescriptor dtDAL::Project::AddResource | ( | const std::string & | newName, | |
| const std::string & | pathToFile, | |||
| const std::string & | category, | |||
| const DataType & | type | |||
| ) |
Adds a resource to the project by copying it into the project.
| newName | the new name of the resource. | |
| pathToFile | The path to the file to copy into the project. | |
| category | The category of the resource file as a dot-notation string. | |
| type | the resounce datatype of the resource. This must be one of the enums that define a resource. |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. | |
| FileExceptionEnum::IOException | if the could not complete because of some sort of IO exception. | |
| ExceptionEnum::ProjectReadOnly | if the project is read only. | |
| FileExceptionEnum::FileNotFound | if the file to import does not exist. | |
| ExceptionEnum::ProjectResourceError | if the file could not be imported if the Datatype is not a resource type. |
| void dtDAL::Project::RemoveResource | ( | const ResourceDescriptor & | resource | ) |
Removes a resource from a project.
This will delete the file if it exists. If no such resource exists, the call will be a noop. This call is not guaranteed to check all actors to make sure the resource is not in use.
| resource | The resource descriptor object. |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. | |
| ExceptionEnum::ProjectReadOnly | if the project is read only. | |
| FileExceptionEnum::IOException | 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. |
| void dtDAL::Project::CreateResourceCategory | ( | const std::string & | category, | |
| const DataType & | type | |||
| ) |
Creates a new resource category.
| category | the category to create. | |
| type | the data type to add the category into. |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. | |
| ExceptionEnum::ProjectReadOnly | if the project is read only. | |
| FileExceptionEnum::IOException | if the operation could not complete because of some sort of IO exception. | |
| ExceptionEnum::ProjectResourceError | if type is not a resource type. |
| bool dtDAL::Project::RemoveResourceCategory | ( | const std::string & | category, | |
| const DataType & | type, | |||
| bool | recursive | |||
| ) |
Removes a category.
| category | The category to remove. | |
| type | The datatype the category is in. | |
| recursive | true to recursively delete the category and all subcategories and resources. |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. | |
| ExceptionEnum::ProjectReadOnly | if the project is read only. | |
| FileExceptionEnum::IOException | if the operation 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. | |
| FileExceptionEnum::FileNotFound | on rare occasion, this could possibly be thrown if the file contents are changed while the recusive delete is occuring. |
| const dtUtil::tree<ResourceTreeNode>& dtDAL::Project::GetAllResources | ( | ) | const [inline] |
See the Project::refresh() method.
| void dtDAL::Project::GetResourcesOfType | ( | const DataType & | type, | |
| dtUtil::tree< ResourceTreeNode > & | toFill | |||
| ) | const |
See the Project::refresh() method.
| toFill | The tree to fill with the results. |
| bool dtDAL::Project::IsArchive | ( | ) | const |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. |
| bool dtDAL::Project::IsReadOnly | ( | ) | const |
| ExceptionEnum::ProjectInvalidContext | if the context is not set. |
| void dtDAL::Project::SetEditMode | ( | bool | pInStage | ) |
This flag will alert actors whether or not there proxy is being loaded into STAGE as a note this should only be set from dtEditQt namespace potential refactor would be to ensure only dtEditQt could set it another implementation would be to have a project state which could control whether we are editing or not if need be we can add a getter for this.
| const bool dtDAL::Project::GetEditMode | ( | ) | const [inline] |
Returns if Project is being executed from STAGE.