Add methods for generating Property descriptions

This commit is contained in:
Alexander Bock
2014-12-12 14:47:08 +01:00
parent efab84b4ba
commit 6360a5f66a
4 changed files with 56 additions and 13 deletions
+27 -4
View File
@@ -205,10 +205,10 @@ public:
* required for creating a GUI representation. The format of the description is a
* valid Lua table, i.e., it is surrounded by a pair of <code>{</code> and
* <code>}</code> with key,value pairs between. Each value can either be a number, a
* string, a bool, or another table. The general values that every Property must set
* string, a bool, or another table. The general values set by this base function
* are: <code>Identifier</code>, <code>Name</code>, <code>Type</code>. All other
* values are specific to the type. If a Property does not override this method, an
* empty string is returned.
* values are specific to the type and are added in a specific subclass, which require
* the subclass to call this method first.
* \return The descriptive text for the Property that can be used for constructing a
* GUI representation
*/
@@ -293,6 +293,16 @@ protected:
static const std::string TypeKey;
static const std::string MetaDataKey;
/**
* Creates the information that is general to every Property and adds the
* <code>Identifier</code>, <code>Name</code>, <code>Type</code>, and
* <code>MetaData</code> keys and their values. The meta data is handles by the
* generateMetaDataDescription method, which has to be overloaded if a concrete base
* class wants to add meta data that is not curated by the Property class
* \return The base description common to all Property classes
*/
std::string generateBaseDescription() const;
/**
* Creates the information for the <code>MetaData</code> key-part of the Lua
* description for the Property. The result can be included as one key-value pair in
@@ -300,7 +310,20 @@ protected:
* Property class is used in this method.
* \return The metadata information text for the property
*/
std::string generateMetaDataDescription() const;
virtual std::string generateMetaDataDescription() const;
/**
* Creates the information that is specific to each subclass of Property%s. If a
* subclass needs to add additional information into the description, it has to
* override this method and return the string containing all of the additional
* information. The base implementation of the #description method will return the Lua
* script:
* <code>return { generateBaseDescription(), generateMetaDataDescription(),</code>
* <code>generateAdditionalDescription()}</code>, which #generateMetaDataDescription
* and this method being the override points to customize the behavior.
* \return The information specific to each subclass of Property
*/
virtual std::string generateAdditionalDescription() const;
/**
* This method must be called by all subclasses whenever the encapsulated value has
@@ -127,6 +127,13 @@ public:
/// \see Property::typeLua
int typeLua() const override;
/**
* Returns the description for this TemplateProperty as a Lua script that returns a
* table on execution
* \return The description for this TemplateProperty
*/
//virtual std::string description() override;
/**
* This operator allows the TemplateProperty to be used almost transparently as if it
* was of the type <code>T</code>. It makes assignments such as
@@ -126,6 +126,11 @@ std::string TemplateProperty<T>::className() const {
return PropertyDelegate<TemplateProperty<T>>::className();
}
//template <typename T>
//std::string TemplateProperty<T>::description() {
// return
//}
template <typename T>
TemplateProperty<T>::operator T() {
return _value;