Classes | Functions | Variables
clanCore Resources

## Classes
class | clan::FileResourceDocument
| File Resource Document. More...
class | clan::FileResourceManager
| Resource manager loading from FileResourceDocument. More...
class | clan::Resource< Type >
| Resource proxy of a specific type. More...
class | clan::Resource_BaseImpl
class | clan::Resource_Impl< Type >
class | clan::ResourceContainer
class | clan::ResourceContainer_Impl
class | clan::ResourceManager
| Resource manager. More...
class | clan::ResourceObject
| Resource proxy of any type. More...
class | clan::XMLResourceDocument
| XML Resource Document. More...
class | clan::XMLResourceManager
| Resource manager loading from XMLResourceDocument. More...
class | clan::XMLResourceNode
| Resource node for a XMLResourceDocument. More...

## Functions
| clan::Resource< Type >::Resource ()
| clan::Resource< Type >::Resource (std::shared_ptr< Resource_Impl< Type > > object)
| clan::Resource< Type >::Resource (const Type &initial_value)
| clan::Resource_Impl< Type >::Resource_Impl ()
| clan::Resource_Impl< Type >::Resource_Impl (const Type &initial_value)
| clan::ResourceContainer::ResourceContainer ()
| clan::ResourceObject::ResourceObject ()
template<typename Type >
| clan::ResourceObject::ResourceObject (const Resource< Type > &resource)
virtual | clan::Resource_BaseImpl::~Resource_BaseImpl ()
static void | clan::XMLResourceManager::add_cache_factory (std::function< void(ResourceManager &, const XMLResourceDocument &)> factory_callback)
| Adds a cache factory callback. More...
static void | clan::FileResourceManager::add_cache_factory (std::function< void(ResourceManager &, const FileResourceDocument &)> factory_callback)
| Adds a cache factory callback. More...
template<typename Type >
Resource< Type > | clan::ResourceObject::cast ()
static ResourceManager | clan::XMLResourceManager::create (const XMLResourceDocument &doc)
| Creates a resource manager. More...
static ResourceManager | clan::FileResourceManager::create (const FileResourceDocument &doc=FileResourceDocument())
| Creates a resource manager. More...
template<typename Type >
Resource< Type > | clan::ResourceContainer::get (const std::string &name)
Type & | clan::Resource< Type >::get ()
const Type & | clan::Resource< Type >::get () const
static XMLResourceDocument & | clan::XMLResourceManager::get_doc (const ResourceManager &manager)
| Gets the XML resource document used by a resource manager. More...
static FileResourceDocument & | clan::FileResourceManager::get_doc (const ResourceManager &manager)
| Gets the XML resource document used by a resource manager. More...
const std::shared_ptr< Resource_Impl< Type > > & | clan::Resource< Type >::handle () const
bool | clan::ResourceObject::is_null () const
| clan::Resource< Type >::operator const Type & () const
| clan::Resource< Type >::operator Type & ()
bool | clan::ResourceObject::operator!= (const ResourceObject &other) const
bool | clan::Resource< Type >::operator!= (const Resource &other) const
Type * | clan::Resource< Type >::operator-> ()
const Type * | clan::Resource< Type >::operator-> () const
bool | clan::ResourceObject::operator< (const ResourceObject &other) const
bool | clan::Resource< Type >::operator< (const Resource &other) const
bool | clan::ResourceObject::operator<= (const ResourceObject &other) const
bool | clan::Resource< Type >::operator<= (const Resource &other) const
bool | clan::ResourceObject::operator== (const ResourceObject &other) const
bool | clan::Resource< Type >::operator== (const Resource &other) const
bool | clan::ResourceObject::operator> (const ResourceObject &other) const
bool | clan::Resource< Type >::operator> (const Resource &other) const
bool | clan::ResourceObject::operator>= (const ResourceObject &other) const
bool | clan::Resource< Type >::operator>= (const Resource &other) const
void | clan::Resource< Type >::set (const Type &value)
bool | clan::Resource< Type >::updated ()

## Variables
int | clan::Resource_Impl< Type >::generation
std::map< std::string, ResourceObject > | clan::ResourceContainer_Impl::resources
Type | clan::Resource_Impl< Type >::value

## Construction
| clan::FileResourceDocument::FileResourceDocument ()
| Construct a FileResourceDocument. More...
| clan::FileResourceDocument::FileResourceDocument (const FileSystem &fs)
| Constructs a FileResourceDocument. More...
| clan::FileResourceDocument::~FileResourceDocument ()

## Attributes
FileSystem | clan::FileResourceDocument::get_file_system () const

## Construction
| clan::ResourceManager::ResourceManager ()
| Construct a ResourceManager. More...
| clan::ResourceManager::~ResourceManager ()

## Attributes
template<typename Type >
std::shared_ptr< Type > | clan::ResourceManager::get_cache (const std::string &name) const

## Operations
template<typename Type >
void | clan::ResourceManager::set_cache (const std::string &name, const std::shared_ptr< Type > &cache)

## Construction
| clan::XMLResourceDocument::XMLResourceDocument ()
| Construct a XMLResourceDocument. More...
| clan::XMLResourceDocument::XMLResourceDocument (const std::string &filename)
| Constructs a XMLResourceDocument. More...
| clan::XMLResourceDocument::XMLResourceDocument (const std::string &filename, FileSystem fs)
| Constructs a XMLResourceDocument. More...
| clan::XMLResourceDocument::XMLResourceDocument (IODevice file, const std::string &base_path, FileSystem fs)
| Constructs a XMLResourceDocument. More...
| clan::XMLResourceDocument::XMLResourceDocument (const XMLResourceDocument &other)
| Constructs a XMLResourceDocument. More...
| clan::XMLResourceDocument::~XMLResourceDocument ()

## Attributes
bool | clan::XMLResourceDocument::resource_exists (const std::string &resource_id) const
| Returns true if a resource exists. More...
std::vector< std::string > | clan::XMLResourceDocument::get_section_names () const
| Returns all the resource sections available. More...
std::vector< std::string > | clan::XMLResourceDocument::get_resource_names () const
| Returns a list of all resources available. More...
std::vector< std::string > | clan::XMLResourceDocument::get_resource_names (const std::string &section) const
std::vector< std::string > | clan::XMLResourceDocument::get_resource_names_of_type (const std::string &type) const
| Returns a list of all resources available matching a given type. More...
std::vector< std::string > | clan::XMLResourceDocument::get_resource_names_of_type (const std::string &type, const std::string &section) const
XMLResourceNode | clan::XMLResourceDocument::get_resource (const std::string &resource_id) const
| Returns Resource representing the given resource. More...
bool | clan::XMLResourceDocument::get_boolean_resource (const std::string &resource_id, bool default_value) const
| Returns the value of a boolean resource. (using the value attribute) More...
int | clan::XMLResourceDocument::get_integer_resource (const std::string &resource_id, int default_value) const
| Returns the value of an integer resource. (using the value attribute) More...
std::string | clan::XMLResourceDocument::get_string_resource (const std::string &resource_id, const std::string &default_value) const
| Returns the value of an string resource. (using the value attribute) More...

## Operations
XMLResourceDocument & | clan::XMLResourceDocument::operator= (const XMLResourceDocument &copy)
bool | clan::XMLResourceDocument::operator== (const XMLResourceDocument &that) const
void | clan::XMLResourceDocument::add_resources (const XMLResourceDocument &additional_resources)
| Add resources from an other resource document. More...
void | clan::XMLResourceDocument::remove_resources (const XMLResourceDocument &additional_resources)
| Remove resources from an other resource document. More...
XMLResourceNode | clan::XMLResourceDocument::create_resource (const std::string &resource_id, const std::string &type)
| Construct a new resource object. More...
void | clan::XMLResourceDocument::destroy_resource (const std::string &resource_id)
| Destroy resource object. More...
void | clan::XMLResourceDocument::save (const std::string &filename)
| Save resource XML tree to file. More...
void | clan::XMLResourceDocument::save (const std::string &filename, const FileSystem &file_system)
| Save. More...
void | clan::XMLResourceDocument::save (IODevice file)
| Save. More...
void | clan::XMLResourceDocument::load (const std::string &filename)
| Load resource XML tree from file. More...
void | clan::XMLResourceDocument::load (const std::string &filename, const FileSystem &file_system)
| Load. More...
void | clan::XMLResourceDocument::load (IODevice file, const std::string &base_path=std::string(), const FileSystem &file_system=FileSystem())
| Load. More...

## Implementation
class | clan::XMLResourceDocument::XMLResourceNode
class | clan::XMLResourceDocument::XMLResourceDocument_Impl

## Construction
| clan::XMLResourceNode::XMLResourceNode ()
| clan::XMLResourceNode::~XMLResourceNode ()

## Attributes
bool | clan::XMLResourceNode::is_null () const
std::string | clan::XMLResourceNode::get_type () const
| Returns the resource type. More...
std::string | clan::XMLResourceNode::get_name () const
| Returns the name of the resource. More...
DomElement & | clan::XMLResourceNode::get_element ()
| Returns the DOM element describing the resource. More...
XMLResourceDocument | clan::XMLResourceNode::get_document ()
| Returns the resource document owning the resource. More...
FileSystem | clan::XMLResourceNode::get_file_system () const
| Returns the file system to load resource from. More...
std::string | clan::XMLResourceNode::get_base_path () const
| Returns the base path of the resource. More...

## Operations
IODevice | clan::XMLResourceNode::open_file (const std::string &filename, File::OpenMode mode=File::open_existing, unsigned int access=File::access_read, unsigned int share=File::share_all, unsigned int flags=0) const
| Opens a file relative to the resource base path. More...
bool | clan::XMLResourceNode::operator== (const XMLResourceNode &other) const
| Compares this resource to another resource. More...

## Implementation
class | clan::XMLResourceNode::XMLResourceDocument

## Detailed Description

## Function Documentation

clan::FileResourceDocument::FileResourceDocument | ( |  | ) |

Construct a FileResourceDocument.

clan::FileResourceDocument::FileResourceDocument | ( | const FileSystem & | fs | ) |

Constructs a FileResourceDocument.

Parameters

  fs | = File system

template<typename Type>

clan::Resource< Type >::Resource | ( |  | ) |
| inline

template<typename Type>

clan::Resource< Type >::Resource | ( | std::shared_ptr< Resource_Impl< Type > > | object | ) |
| inline

template<typename Type>

clan::Resource< Type >::Resource | ( | const Type & | initial_value | ) |
| inline

template<typename Type >

clan::Resource_Impl< Type >::Resource_Impl | ( |  | ) |
| inline

template<typename Type >

clan::Resource_Impl< Type >::Resource_Impl | ( | const Type & | initial_value | ) |
| inline

clan::ResourceContainer::ResourceContainer | ( |  | ) |
| inline

clan::ResourceManager::ResourceManager | ( |  | ) |

Construct a ResourceManager.

clan::ResourceObject::ResourceObject | ( |  | ) |
| inline

template<typename Type >

clan::ResourceObject::ResourceObject | ( | const Resource< Type > & | resource | ) |
| inline

clan::XMLResourceDocument::XMLResourceDocument | ( |  | ) |

Construct a XMLResourceDocument.

clan::XMLResourceDocument::XMLResourceDocument | ( | const std::string & | filename | ) |

Constructs a XMLResourceDocument.

Parameters

  filename | = String

clan::XMLResourceDocument::XMLResourceDocument | ( | const std::string & | filename,
|  | FileSystem | fs
| ) |  |

Constructs a XMLResourceDocument.

Parameters

  filename | = String
  directory | = Virtual Directory

clan::XMLResourceDocument::XMLResourceDocument | ( | IODevice | file,
|  | const std::string & | base_path,
|  | FileSystem | fs
| ) |  |

Constructs a XMLResourceDocument.

Parameters

  file | = IODevice
  directory | = Virtual Directory

clan::XMLResourceDocument::XMLResourceDocument | ( | const XMLResourceDocument & | other | ) |

Constructs a XMLResourceDocument.

Parameters

  other | = XMLResourceDocument

clan::XMLResourceNode::XMLResourceNode | ( |  | ) |

clan::FileResourceDocument::~FileResourceDocument | ( |  | ) |

virtual clan::Resource_BaseImpl::~Resource_BaseImpl | ( |  | ) |
| inline virtual

clan::ResourceManager::~ResourceManager | ( |  | ) |

clan::XMLResourceDocument::~XMLResourceDocument | ( |  | ) |

clan::XMLResourceNode::~XMLResourceNode | ( |  | ) |

static void clan::XMLResourceManager::add_cache_factory | ( | std::function< void(ResourceManager &, const XMLResourceDocument &)> | factory_callback | ) |
| static

Adds a cache factory callback.

Each factory callback is invoked every time a resource manager is created.

static void clan::FileResourceManager::add_cache_factory | ( | std::function< void(ResourceManager &, const FileResourceDocument &)> | factory_callback | ) |
| static

Adds a cache factory callback.

Each factory callback is invoked every time a resource manager is created.

void clan::XMLResourceDocument::add_resources | ( | const XMLResourceDocument & | additional_resources | ) |

Add resources from an other resource document.

This function only makes the resource document search other documents, it does not copy the resources into this document.

template<typename Type >

Resource<Type> clan::ResourceObject::cast | ( |  | ) |
| inline

static ResourceManager clan::XMLResourceManager::create | ( | const XMLResourceDocument & | doc | ) |
| static

Creates a resource manager.

static ResourceManager clan::FileResourceManager::create | ( | const FileResourceDocument & | doc = `FileResourceDocument()` | ) |
| static

Creates a resource manager.

XMLResourceNode clan::XMLResourceDocument::create_resource | ( | const std::string & | resource_id,
|  | const std::string & | type
| ) |  |

Construct a new resource object.

void clan::XMLResourceDocument::destroy_resource | ( | const std::string & | resource_id | ) |

Destroy resource object.

template<typename Type >

Resource<Type> clan::ResourceContainer::get | ( | const std::string & | name | ) |
| inline

template<typename Type>

Type& clan::Resource< Type >::get | ( |  | ) |
| inline

template<typename Type>

const Type& clan::Resource< Type >::get | ( |  | ) | const
| inline

std::string clan::XMLResourceNode::get_base_path | ( |  | ) | const

Returns the base path of the resource.

bool clan::XMLResourceDocument::get_boolean_resource | ( | const std::string & | resource_id,
|  | bool | default_value
| ) |  | const

Returns the value of a boolean resource. (using the value attribute)

template<typename Type >

std::shared_ptr<Type> clan::ResourceManager::get_cache | ( | const std::string & | name | ) | const
| inline

References clan::UserDataOwner::get_data().

static XMLResourceDocument& clan::XMLResourceManager::get_doc | ( | const ResourceManager & | manager | ) |
| static

Gets the XML resource document used by a resource manager.

static FileResourceDocument& clan::FileResourceManager::get_doc | ( | const ResourceManager & | manager | ) |
| static

Gets the XML resource document used by a resource manager.

XMLResourceDocument clan::XMLResourceNode::get_document | ( |  | ) |

Returns the resource document owning the resource.

DomElement& clan::XMLResourceNode::get_element | ( |  | ) |

Returns the DOM element describing the resource.

FileSystem clan::FileResourceDocument::get_file_system | ( |  | ) | const

FileSystem clan::XMLResourceNode::get_file_system | ( |  | ) | const

Returns the file system to load resource from.

int clan::XMLResourceDocument::get_integer_resource | ( | const std::string & | resource_id,
|  | int | default_value
| ) |  | const

Returns the value of an integer resource. (using the value attribute)

std::string clan::XMLResourceNode::get_name | ( |  | ) | const

Returns the name of the resource.

XMLResourceNode clan::XMLResourceDocument::get_resource | ( | const std::string & | resource_id | ) | const

Returns Resource representing the given resource.

std::vector<std::string> clan::XMLResourceDocument::get_resource_names | ( |  | ) | const

Returns a list of all resources available.

The returned resources are in the form "section/subsection/.../resourcename".

std::vector<std::string> clan::XMLResourceDocument::get_resource_names | ( | const std::string & | section | ) | const

std::vector<std::string> clan::XMLResourceDocument::get_resource_names_of_type | ( | const std::string & | type | ) | const

Returns a list of all resources available matching a given type.

The returned resources are in the form "section/subsection/.../resourcename".

std::vector<std::string> clan::XMLResourceDocument::get_resource_names_of_type | ( | const std::string & | type,
|  | const std::string & | section
| ) |  | const

std::vector<std::string> clan::XMLResourceDocument::get_section_names | ( |  | ) | const

Returns all the resource sections available.

std::string clan::XMLResourceDocument::get_string_resource | ( | const std::string & | resource_id,
|  | const std::string & | default_value
| ) |  | const

Returns the value of an string resource. (using the value attribute)

std::string clan::XMLResourceNode::get_type | ( |  | ) | const

Returns the resource type.

template<typename Type>

const std::shared_ptr<Resource_Impl<Type> >& clan::Resource< Type >::handle | ( |  | ) | const
| inline

bool clan::ResourceObject::is_null | ( |  | ) | const
| inline

bool clan::XMLResourceNode::is_null | ( |  | ) | const

void clan::XMLResourceDocument::load | ( | const std::string & | filename | ) |

Load resource XML tree from file.

void clan::XMLResourceDocument::load | ( | const std::string & | filename,
|  | const FileSystem & | file_system
| ) |  |

Load.

Parameters

  filename | = the filename to save
  directory | = Virtual Directory

void clan::XMLResourceDocument::load | ( | IODevice | file,
|  | const std::string & | base_path = `std::string()`,
|  | const FileSystem & | file_system = `FileSystem()`
| ) |  |

Load.

Parameters

  file | = the file to load
  directory | = Virtual Directory

IODevice clan::XMLResourceNode::open_file | ( | const std::string & | filename,
|  | File::OpenMode | mode = `File::open_existing`,
|  | unsigned int | access = `File::access_read`,
|  | unsigned int | share = `File::share_all`,
|  | unsigned int | flags = `0`
| ) |  | const

Opens a file relative to the resource base path.

param: mode = File::OpenMode modes param: access = File::AccessFlags flags param: share = File::ShareFlags flags param: flags = File::Flags flags

Returns
  The IODevice

template<typename Type>

clan::Resource< Type >::operator const Type & | ( |  | ) | const
| inline

template<typename Type>

clan::Resource< Type >::operator Type & | ( |  | ) |
| inline

bool clan::ResourceObject::operator!= | ( | const ResourceObject & | other | ) | const
| inline

template<typename Type>

bool clan::Resource< Type >::operator!= | ( | const Resource< Type > & | other | ) | const
| inline

template<typename Type>

Type* clan::Resource< Type >::operator-> | ( |  | ) |
| inline

template<typename Type>

const Type* clan::Resource< Type >::operator-> | ( |  | ) | const
| inline

bool clan::ResourceObject::operator< | ( | const ResourceObject & | other | ) | const
| inline

template<typename Type>

bool clan::Resource< Type >::operator< | ( | const Resource< Type > & | other | ) | const
| inline

bool clan::ResourceObject::operator<= | ( | const ResourceObject & | other | ) | const
| inline

template<typename Type>

bool clan::Resource< Type >::operator<= | ( | const Resource< Type > & | other | ) | const
| inline

XMLResourceDocument& clan::XMLResourceDocument::operator= | ( | const XMLResourceDocument & | copy | ) |

bool clan::ResourceObject::operator== | ( | const ResourceObject & | other | ) | const
| inline

bool clan::XMLResourceNode::operator== | ( | const XMLResourceNode & | other | ) | const

Compares this resource to another resource.

template<typename Type>

bool clan::Resource< Type >::operator== | ( | const Resource< Type > & | other | ) | const
| inline

bool clan::XMLResourceDocument::operator== | ( | const XMLResourceDocument & | that | ) | const

bool clan::ResourceObject::operator> | ( | const ResourceObject & | other | ) | const
| inline

template<typename Type>

bool clan::Resource< Type >::operator> | ( | const Resource< Type > & | other | ) | const
| inline

bool clan::ResourceObject::operator>= | ( | const ResourceObject & | other | ) | const
| inline

template<typename Type>

bool clan::Resource< Type >::operator>= | ( | const Resource< Type > & | other | ) | const
| inline

void clan::XMLResourceDocument::remove_resources | ( | const XMLResourceDocument & | additional_resources | ) |

Remove resources from an other resource document.

bool clan::XMLResourceDocument::resource_exists | ( | const std::string & | resource_id | ) | const

Returns true if a resource exists.

void clan::XMLResourceDocument::save | ( | const std::string & | filename | ) |

Save resource XML tree to file.

void clan::XMLResourceDocument::save | ( | const std::string & | filename,
|  | const FileSystem & | file_system
| ) |  |

Save.

Parameters

  filename | = the filename to save
  directory | = Virtual Directory

void clan::XMLResourceDocument::save | ( | IODevice | file | ) |

Save.

Parameters

  file | = IODevice

template<typename Type>

void clan::Resource< Type >::set | ( | const Type & | value | ) |
| inline

template<typename Type >

void clan::ResourceManager::set_cache | ( | const std::string & | name,
|  | const std::shared_ptr< Type > & | cache
| ) |  |
| inline

References clan::UserDataOwner::set_data().

template<typename Type>

bool clan::Resource< Type >::updated | ( |  | ) |
| inline

## Variable Documentation

template<typename Type >

int clan::Resource_Impl< Type >::generation

std::map<std::string, ResourceObject> clan::ResourceContainer_Impl::resources

template<typename Type >

Type clan::Resource_Impl< Type >::value

## Friends

friend class XMLResourceDocument
| friend

friend class XMLResourceDocument_Impl
| friend

friend class XMLResourceNode
| friend