[DOC] add documentations

This commit is contained in:
Edouard DUPIN 2014-09-05 21:42:04 +02:00
parent 886f4ddc76
commit 6ad49453ba
4 changed files with 161 additions and 8 deletions

View File

@ -1,6 +1,113 @@
=== Objectif ===
=== Objectifs ===
:** Understand What is a resource
:** Use resources
=== What is a resource: ===
A resource is an usique element that can be used by manny element like:
:** An image (special resolution)
:** A configuration file
:** An application manager (special case)
:** A sound file
:** ...
A resource have an other objective, form some platform, the graphic interface can be stopped, then we need to reload texture in the graphic inteface...
Then the texture is an other graphic interface.
=== Get a resource: ===
For this example we will load a configuration file:
[code style=c++]
#include <ewol/object/Object.h>
#include <ewol/resource/ConfigFile.h>
namespace appl {
class MyObj : public ewol::Object {
private:
std::shared_ptr<ewol::resource::ConfigFile> m_config;
int32_t m_configValId;
protected:
//! @brief Constructor
MyObj(void) :
m_configValId(-1) {
// nothing to do..
}
void init() {
ewol::Object::init();
m_config = ewol::resource::ConfigFile::create("DATA:ExapleConfig.json");
m_configValId = m_config->request("exampleConfigName");
}
public:
//! @brief Destructor
virtual ~MyObj(void) { }
DECLARE_FACTORY(MyObj);
public:
void process() {
double value = m_config->getNumber(m_configValId);
APPL_DEBUG("example value : " << value);
}
}
}
[/code]
=== Create a new resource: ===
A resource is a generic [class[ewol::Resource]] that hrited form a generic [class[ewol::Object]], simply change the FACTORY macro in :
:** DECLARE_RESOURCE_FACTORY(className) To declare a resource with no name (unique for every creation)
:** DECLARE_RESOURCE_NAMED_FACTORY(className) To create a resource that have a specific name. When created, we will find the previous resource with the specify name in the fanctory.
:** DECLARE_RESOURCE_SINGLE_FACTORY(className,uniqueName) This is to have a unique resource for all the application (name is specify in the Macro)
we have now some specific interface to compleate (if needed):
==== The Resource Level ====
The resources can be reloaded, then we need to reaload in the good order (level [0 .. 5])
The resources are loaded fron 0 to 5.
Then for basic resource :
[code style=c++]
#include <ewol/object/Resource.h>
namespace appl {
class MyResource : public ewol::Resource {
protected:
//! @brief Constructor
MyResource() :
m_configValId(-1) {
m_resourceLevel = 4;
addObjectType("ewol::MyResource");
}
void init(const std::& _name) {
ewol::Resource::init(_name);
}
public:
//! @brief Destructor
virtual ~MyResource(void) { }
DECLARE_RESOURCE_NAMED_FACTORY(MyResource);
}
}
[/code]
Now we need to implement somme functions:
To send data on the hardware (openGL):
[code style=c++]
void updateContext();
[/code]
To remove data from the the hardware (openGL):
[code style=c++]
void removeContext();
[/code]
When loose hardware (juste update internal state):
[code style=c++]
void removeContextToLate();
[/code]
When user request to reload all resources (can be usefull when using file type : THEME:GUI:xxx)
[code style=c++]
void reload();
[/code]

View File

@ -1,7 +1,15 @@
=== Objectif ===
:** What is a Widget
:** Simply create a comple Gui
:** Simply create a complex Gui
=== What is a Widget ===
=== Simple load of a widget: ===
see the basic tuttorial: [tutorial[001_Hello_Word | Hello world]]
=== Create an interface with a XML form: ===

2
monk

@ -1 +1 @@
Subproject commit 6c7b028c50b5c5862ad1c2c1a7f3c0cce8b29aae
Subproject commit 71ded394c57b4ed8954643eacde359c1a9bab52c

View File

@ -90,31 +90,69 @@ namespace ewol {
namespace resource {
class Manager;
};
// class resources is pure virtual
/**
* @brief A Resource is a generic interface to have an instance that have things that can be used by many people, ad have some hardware dependency.
* For example of resources :
* :** Shaders: openGL display interface.
* :** Texture: openGL imega interface.
* :** Font: Single file interface to store many glyphe ==> reduce the number of parallele loaded files.
* :** ConfigFile: simple widget configuration files
* :** ...
*/
class Resource : public ewol::Object {
protected:
/**
* @brief generic protected contructor (use factory to create this class)
*/
Resource() :
m_resourceLevel(MAX_RESOURCE_LEVEL-1) {
addObjectType("ewol::Resource");
setStatusResource(true);
};
/**
* @brief Initialisation of the class and previous classes.
* @param[in] _name Name of the resource.
*/
void init();
//! @previous
void init(const std::string& _name);
public:
//! geenric destructor
virtual ~Resource() {
};
protected:
uint8_t m_resourceLevel; //!< Level of the resource ==> for updata priority [0..5] 0 must be update first.
uint8_t m_resourceLevel; //!< Level of the resource ==> for update priority [0..5] 0 must be update first.
public:
uint8_t getResourceLevel() {
/**
* @brief Get the current resource level;
* @return value in [0..5]
*/
uint8_t getResourceLevel() {
return m_resourceLevel;
};
/**
* @brief Call when need to send data on the harware (openGL)
* @note This is done asynchronously with the create of the Resource.
*/
virtual void updateContext();
/**
* @brief The current OpenGl context is removing ==> remove yout own system data
*/
virtual void removeContext();
/**
* @brief The notification of the Context removing is too late, we have no more acces on the OpenGl context (thank you Android).
* Juste update your internal state
*/
virtual void removeContextToLate();
/**
* @brief User request the reload of all resources (usefull when the file depend on DATA:GUI:xxx ...
*/
virtual void reload();
protected:
/**
* @brief Get the current resource Manager
*/
static ewol::resource::Manager& getManager();
};
};