Ocular Engine
|
#include <Exposable.hpp>
Public Member Functions | |
void | getAllExposedNames (std::vector< std::string > &names) const |
bool | getVariable (std::string const &name, ExposedVariable &var) |
template<typename T > | |
bool | getVariableValue (std::string const &name, T &var) |
template<typename T > | |
bool | setVariableValue (std::string const &name, T const &value) |
virtual void | onVariableModified (std::string const &varName) |
Protected Member Functions | |
void | exposeVariable (std::string const &name, std::string const &type, bool isPointer, bool isExposed, void *data) |
Protected Attributes | |
std::unordered_map< std::string, ExposedVariable > | m_ExposedVariables |
Friends | |
class | Buildable |
When inheriting from Exposable, an object is allowing for selected variables and pointers to be inspected, and potentially modified, by any outside source.
While external behaviour can not be guaranteed, the Ocular Engine will only inspect or modify variables when generic access is required. This typically falls under the following scenarios:
- Loading object from file - Saving object to file - Ocular Editor inspection
Many fundamental classes inherit from Exposable (including SceneObjects, Renderables, Routines, various Resources, etc.) in order to allow for the above scenarios to take place.
A class that inherits from Exposable may also see special automatic behaviour when also inheriting from the Buildable class. This typically includes automatic building from, and saving to, BuilderNode chains.
|
protected |
Exposes the specified member variable so that it's value can be retrieved or modified by anyone. This includes protected and private variables.
Internally (ie by the Ocular engine itself) this is typically only used for saving/loading purposes (or by the editor application). But it's use is in no way limited to just the engine.
[in] | name | Full unique case-sensitive name of the member variable |
[in] | type | String representation of the member variable type (see OCULAR_TYPE macro) |
[in] | isPointer | Set to TRUE if the variable is a pointer |
[in] | isExposed | Set to TRUE if the variable inherits from Exposable |
[in] | ptr | Pointer to the member variable to expose |
void Ocular::Core::Exposable::getAllExposedNames | ( | std::vector< std::string > & | names | ) | const |
Fills a vector with the names of all exposed variables. These names can then be used with the various get/set variable methods.
[out] | names |
bool Ocular::Core::Exposable::getVariable | ( | std::string const & | name, |
ExposedVariable & | var | ||
) |
Attempts to retrieve the specified exposed variable.
[in] | name | |
[out] | var |
|
inline |
Attempts to retrieve the value of the specified exposed variable.
[in] | name | |
[out] | var |
|
virtual |
Optional method that should be called after modifying an exposed variable. This allows the implementation a chance to react to the modification if necessary.
Reimplemented in Ocular::Math::Transform, Ocular::Core::SceneObject, and Ocular::Core::PointLight.
|
inline |
Attempts to set the value of the specified exposed variable.
[in] | name | |
[in] | value |