Ocular Engine
Ocular::Core::Exposable Class Reference

#include <Exposable.hpp>

Inheritance diagram for Ocular::Core::Exposable:
Ocular::Core::ObjectIO Ocular::Core::Object Ocular::Graphics::Material Ocular::Math::Transform Ocular::Core::AEvent Ocular::Core::ARenderable Ocular::Core::ARoutine Ocular::Core::AWindow Ocular::Core::SceneObject Ocular::Graphics::D3D11Material Ocular::Graphics::MaterialEmpty Ocular::Graphics::MaterialMissing

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, ExposedVariablem_ExposedVariables


class Buildable

Detailed Description

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.

Member Function Documentation

void Ocular::Core::Exposable::exposeVariable ( std::string const &  name,
std::string const &  type,
bool  isPointer,
bool  isExposed,
void *  data 

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.

If a variable with the specified name was already exposed, then no action will be taken.
[in]nameFull unique case-sensitive name of the member variable
[in]typeString representation of the member variable type (see OCULAR_TYPE macro)
[in]isPointerSet to TRUE if the variable is a pointer
[in]isExposedSet to TRUE if the variable inherits from Exposable
[in]ptrPointer 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.

The provided vector is cleared prior to any names being added
bool Ocular::Core::Exposable::getVariable ( std::string const &  name,
ExposedVariable var 

Attempts to retrieve the specified exposed variable.

TRUE if a variable was exposed with the specified name
template<typename T >
bool Ocular::Core::Exposable::getVariableValue ( std::string const &  name,
T &  var 

Attempts to retrieve the value of the specified exposed variable.

TRUE if a variable was exposed with the specified name and matching type
void Ocular::Core::Exposable::onVariableModified ( std::string const &  varName)

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.

template<typename T >
bool Ocular::Core::Exposable::setVariableValue ( std::string const &  name,
T const &  value 

Attempts to set the value of the specified exposed variable.

TRUE if successfully set the value of the specified variable. May fail if no variable with the given name was found and/or if variable type did not match.

The documentation for this class was generated from the following files: