Adding 'property' prefix to subowner methods in PropertyOwner

Added function for writing documentation of properties
This commit is contained in:
Alexander Bock
2015-02-22 22:05:25 +01:00
parent 5be1c4163f
commit a7bd6319db
7 changed files with 60 additions and 26 deletions
-16
View File
@@ -67,22 +67,6 @@ public:
bool _isEnabled;
bool _showHelp;
//ghoul::SharedMemory* _performanceMemory;
//float _minMaxValues[2];
//std::set<properties::Property*> _boolProperties;
//std::set<properties::Property*> _intProperties;
//std::set<properties::Property*> _floatProperties;
//std::set<properties::Property*> _vec2Properties;
//std::set<properties::Property*> _vec3Properties;
//std::set<properties::Property*> _vec4Properties;
//std::set<properties::Property*> _stringProperties;
//std::set<properties::Property*> _optionProperty;
//std::set<properties::Property*> _selectionProperty;
//std::set<properties::Property*> _triggerProperty;
//std::map<std::string, std::vector<properties::Property*>> _propertiesByOwner;
};
} // namespace gui
+3 -3
View File
@@ -123,7 +123,7 @@ public:
* this PropertyOwner.
* \return A list of all sub-owners this PropertyOwner has
*/
const std::vector<PropertyOwner*>& subOwners() const;
const std::vector<PropertyOwner*>& propertySubOwners() const;
/**
* This method returns the direct sub-owner of this PropertyOwner with the provided
@@ -134,7 +134,7 @@ public:
* \param name The name of the sub-owner that should be returned
* \return The PropertyOwner with the given <code>name</code>, or <code>nullptr</code>
*/
PropertyOwner* subOwner(const std::string& name) const;
PropertyOwner* propertySubOwner(const std::string& name) const;
/**
* Returns <code>true</code> if this PropertyOwner owns a sub-owner with the provided
@@ -143,7 +143,7 @@ public:
* \return <code>true</code> if this PropertyOwner owns a sub-owner with the provided
* <code>name</code>; returns <code>false</code> otherwise
*/
bool hasSubOwner(const std::string& name) const;
bool hasPropertySubOwner(const std::string& name) const;
/**
* This method converts a provided <code>groupID</code>, used by the Propertys, into a
@@ -110,6 +110,8 @@ public:
private:
bool loadSceneInternal(const std::string& sceneDescriptionFilePath);
void writePropertyDocumentation(const std::string& filename, const std::string& type);
std::string _focus;
// actual scenegraph
+2
View File
@@ -44,6 +44,8 @@ namespace configurationmanager {
const std::string keyConfigSgct = "SGCTConfig";
const std::string keyLuaDocumentationType = "LuaDocumentationFile.Type";
const std::string keyLuaDocumentationFile = "LuaDocumentationFile.File";
const std::string keyPropertyDocumentationType = "PropertyDocumentationFile.Type";
const std::string keyPropertyDocumentationFile = "PropertyDocumentationFile.File";
const std::string keyConfigScene = "Scene";
const std::string keyEnableGui = "EnableGUI";
const std::string keyStartupScript = "StartupScripts";
+4
View File
@@ -38,6 +38,10 @@ return {
Type = "text",
File = "${BASE_PATH}/LuaScripting.txt"
},
PropertyDocumentationFile = {
Type = "text",
File = "${BASE_PATH}/Properties.txt"
},
SGCTConfig = "${SGCT}/single.xml",
--SGCTConfig = "${SGCT}/single_fisheye.xml",
--SGCTConfig = "${SGCT}/two_nodes.xml",
+6 -6
View File
@@ -96,7 +96,7 @@ Property* PropertyOwner::property(const std::string& id) const
const std::string ownerName = id.substr(0, ownerSeparator);
const std::string propertyName = id.substr(ownerSeparator + 1);
PropertyOwner* owner = subOwner(ownerName);
PropertyOwner* owner = propertySubOwner(ownerName);
if (owner == nullptr) {
return nullptr;
}
@@ -114,11 +114,11 @@ bool PropertyOwner::hasProperty(const std::string& id) const {
return property(id) != nullptr;
}
const std::vector<PropertyOwner*>& PropertyOwner::subOwners() const {
const std::vector<PropertyOwner*>& PropertyOwner::propertySubOwners() const {
return _subOwners;
}
PropertyOwner* PropertyOwner::subOwner(const std::string& name) const {
PropertyOwner* PropertyOwner::propertySubOwner(const std::string& name) const {
assert(std::is_sorted(_subOwners.begin(), _subOwners.end(), subOwnerLess));
// As the _subOwners list is sorted, getting the lower bound is sufficient
@@ -134,8 +134,8 @@ PropertyOwner* PropertyOwner::subOwner(const std::string& name) const {
return *it;
}
bool PropertyOwner::hasSubOwner(const std::string& name) const {
return subOwner(name) != nullptr;
bool PropertyOwner::hasPropertySubOwner(const std::string& name) const {
return propertySubOwner(name) != nullptr;
}
void PropertyOwner::setPropertyGroupName(std::string groupID, std::string name)
@@ -179,7 +179,7 @@ void PropertyOwner::addProperty(Property* prop)
return;
} else {
// Otherwise we still have to look if there is a PropertyOwner with the same name
const bool hasOwner = hasSubOwner(prop->identifier());
const bool hasOwner = hasPropertySubOwner(prop->identifier());
if (hasOwner) {
LERROR("Property identifier '" << prop->identifier() << "' already names a"
<< "registed PropertyOwner");
+43 -1
View File
@@ -480,10 +480,25 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath)
std::vector<properties::Property*> properties = node->propertiesRecursive();
for (properties::Property* p : properties) {
OsEng.gui()->_property.registerProperty(p);
//OsEng.gui()->_property.registerProperty(p->description());
}
}
// If a LuaDocumentationFile was specified, generate it now
using constants::configurationmanager::keyPropertyDocumentationType;
using constants::configurationmanager::keyPropertyDocumentationFile;
const bool hasType = OsEng.configurationManager()->hasKey(keyPropertyDocumentationType);
const bool hasFile = OsEng.configurationManager()->hasKey(keyPropertyDocumentationFile);
if (hasType && hasFile) {
std::string propertyDocumentationType;
OsEng.configurationManager()->getValue(keyPropertyDocumentationType, propertyDocumentationType);
std::string propertyDocumentationFile;
OsEng.configurationManager()->getValue(keyPropertyDocumentationFile, propertyDocumentationFile);
propertyDocumentationFile = absPath(propertyDocumentationFile);
writePropertyDocumentation(propertyDocumentationFile, propertyDocumentationType);
}
OsEng.runSettingsScripts();
return true;
@@ -642,6 +657,33 @@ std::vector<SceneGraphNode*> SceneGraph::allSceneGraphNodes() const {
return _nodes;
}
void SceneGraph::writePropertyDocumentation(const std::string& filename, const std::string& type) {
if (type == "text") {
LDEBUG("Writing documentation for properties");
std::ofstream file(filename);
if (!file.good()) {
LERROR("Could not open file '" << filename << "' for writing property documentation");
return;
}
using properties::Property;
for (SceneGraphNode* node : _nodes) {
std::vector<Property*> properties = node->propertiesRecursive();
if (!properties.empty()) {
file << node->name() << std::endl;
for (Property* p : properties) {
file << p->fullyQualifiedIdentifier() << ": " << p->guiName() << std::endl;
}
file << std::endl;
}
}
}
else
LERROR("Undefined type '" << type << "' for Property documentation");
}
scripting::ScriptEngine::LuaLibrary SceneGraph::luaLibrary() {
return {
"",