Convenience-extended version of QObjects for use with Gluon. More...
#include <gluonobject.h>
Public Member Functions | |
GLUON_OBJECT (GluonCore::GluonObject) | |
Q_INVOKABLE | GluonObject (QObject *parent=0) |
GluonObject (const QString &name, QObject *parent=0) | |
GluonObject (const GluonObject &rt) | |
virtual | ~GluonObject () |
Q_INVOKABLE void | debug (const QString &debugText) const |
Q_INVOKABLE void | debug (const QString &debugText, const QString &arg) const |
Q_SIGNAL void | showDebug (const QString &debugText) const |
Q_INVOKABLE GluonObject * | clone () const |
Q_INVOKABLE GluonObject * | clone (GluonObject *parentObject) const |
virtual QString | name () const |
virtual void | setName (const QString &newName) |
QString | fullyQualifiedName () const |
QString | fullyQualifiedFileName () const |
virtual const QStringList | supportedMimeTypes () const |
GluonObject * | gameProject () const |
void | setGameProject (GluonObject *newGameProject) |
Q_INVOKABLE MetaInfo * | metaInfo () |
Q_INVOKABLE bool | hasMetaInfo () const |
virtual QString | toGDL (int indentLevel=0) const |
virtual QString | childrenToGDL (int indentLevel=0) const |
virtual QString | propertiesToGDL (int indentLevel=0) const |
virtual void | setPropertyFromString (const QString &propertyName, const QString &propertyValue) |
virtual QString | stringFromProperty (const QString &propertyName, const QString &indentChars) const |
virtual void | sanitize () |
Q_INVOKABLE GluonObject * | findItemByName (QString qualifiedName) |
virtual Q_INVOKABLE GluonObject * | root () |
virtual void | addChild (GluonObject *child) |
virtual bool | removeChild (GluonObject *child) |
virtual GluonObject * | child (int index) const |
virtual GluonObject * | child (const QString &name) const |
Protected Member Functions | |
virtual void | postCloneSanitize () |
Static Protected Member Functions | |
static GluonObject * | findItemByNameInObject (QStringList qualifiedName, GluonCore::GluonObject *object) |
Properties | |
QString | name |
Convenience-extended version of QObjects for use with Gluon.
The central object class for Gluon - it contains much convenience functionality used throughout Gluon, specifically geared towards searching and the like. It further extends QObject with extra functionality to help with certain specifics for properties, that Qt's properties do not support, such as value borders and steps for numerical values.
Subclassing
When implementing GluonObject subclasses in C++, please remember the following items in your code:
Definition (yourclassname.h):
#include <gluonobject.h> namespace YourNamespace { class YourClassName : public GluonCore::GluonObject { Q_OBJECT GLUON_OBJECT(YourNamespace::YourClassName); public: Q_INVOKABLE YourClassName(QObject *parent = 0); virtual ~YourClassName(); // More functions here... private: } } Q_DECLARE_METATYPE(YourNamespace::YourClassName); Q_DECLARE_METATYPE(YourNamespace::YourClassName*);
Implementation (yourclassname.cpp):
#include "yourclassname.h" REGISTER_OBJECT_TYPE(YourNamespace, YourClassName); using YourNamespace; YourClassName::YourClassName(QObject *parent) : GluonObject(parent) { } YourClassName::~YourClassName() { } // further implementation here... #include "yourclassname.moc"
Please also ensure that all public functions are slots, as this will enable their access from the QtScript based game code in GluonEngine based games.
Definition at line 133 of file gluonobject.h.
GluonObject::GluonObject | ( | QObject * | parent = 0 |
) |
Definition at line 39 of file gluonobject.cpp.
GluonObject::GluonObject | ( | const QString & | name, | |
QObject * | parent = 0 | |||
) | [explicit] |
Definition at line 51 of file gluonobject.cpp.
GluonObject::GluonObject | ( | const GluonObject & | rt | ) |
Definition at line 58 of file gluonobject.cpp.
GluonObject::~GluonObject | ( | ) | [virtual] |
Definition at line 63 of file gluonobject.cpp.
void GluonObject::addChild | ( | GluonObject * | child | ) | [virtual] |
Add the passed GluonObject as a new child to this object. The function will ensure that the name is correct
child | The new child |
Reimplemented in GluonEngine::GameObject.
Definition at line 357 of file gluonobject.cpp.
GluonObject * GluonObject::child | ( | const QString & | name | ) | const [virtual] |
Convenience function for fetching a child by a specified name
name | The name of the child you wish to fetch
|
Definition at line 368 of file gluonobject.cpp.
GluonObject * GluonObject::child | ( | int | index | ) | const [virtual] |
Convenience function for getting a child at a specific index in the list of children
index | The index of the child you wish to fetch
|
Definition at line 363 of file gluonobject.cpp.
QString GluonObject::childrenToGDL | ( | int | indentLevel = 0 |
) | const [virtual] |
Reimplemented in GluonEngine::Asset, and GluonEngine::MaterialAsset.
Definition at line 411 of file gluonobject.cpp.
GluonObject * GluonObject::clone | ( | GluonObject * | parentObject | ) | const |
Copy this object and all of its children, recursively, and insert the cloned object as a child of the passed GluonObject
Definition at line 99 of file gluonobject.cpp.
GluonObject * GluonObject::clone | ( | ) | const |
Copy this object and all of its children, resursively. It will be a child of the same GluonObject that the current object is a child of.
Definition at line 84 of file gluonobject.cpp.
void GluonObject::debug | ( | const QString & | debugText, | |
const QString & | arg | |||
) | const |
Write a debug statement to the console and into the debug messages pane in Gluon Creator when running a game from inside the tool.
debugText | The message you wish to write out
|
Definition at line 76 of file gluonobject.cpp.
void GluonObject::debug | ( | const QString & | debugText | ) | const |
Write a debug statement to the console and into the debug messages pane in Gluon Creator when running a game from inside the tool.
debugText | The message you wish to write out |
Definition at line 68 of file gluonobject.cpp.
GluonCore::GluonObject * GluonObject::findItemByName | ( | QString | qualifiedName | ) |
Attempt to locate an object by the specified qualified name, starting the search from the object is called on. To search the full tree, for example for use with fullyQualifiedName, call this function on the object returned by root()
qualifiedName | The path (with object names separated by the / symbol) to the object, relative to the object this function is called on
|
Definition at line 339 of file gluonobject.cpp.
GluonObject * GluonObject::findItemByNameInObject | ( | QStringList | qualifiedName, | |
GluonCore::GluonObject * | object | |||
) | [static, protected] |
Convenience function which will find objects inside a passed GluonObject which fit the also passed qualified name. The function is used internally by findItemByName() but could well be useful for other things as well.
qualifiedName | The qualified name of the object you wish to locate
|
Definition at line 677 of file gluonobject.cpp.
QString GluonObject::fullyQualifiedFileName | ( | ) | const |
A version of the fully qualified name of the object suitable for use as a file name. Note that this is NOT the actual file name of any file on the disk, it is only a string which is suitable for use as a file name
Definition at line 319 of file gluonobject.cpp.
QString GluonObject::fullyQualifiedName | ( | ) | const |
The fully qualified name of the object, from the root and upwards. The object name separator is / which means that an object named AnObject which is child of the top level object AnotherObject is: AnotherObject/AnObject
Definition at line 310 of file gluonobject.cpp.
GluonObject * GluonObject::gameProject | ( | ) | const |
Use this to access functions on the GameProject instance associated with this GluonObject.
Definition at line 233 of file gluonobject.cpp.
GluonCore::GluonObject::GLUON_OBJECT | ( | GluonCore::GluonObject | ) |
bool GluonObject::hasMetaInfo | ( | ) | const |
Request information on whether the class contains MetaInfo. This function is needed to ensure the ability to read metaInfo without creating one automatically.
Definition at line 768 of file gluonobject.cpp.
MetaInfo * GluonObject::metaInfo | ( | ) |
Get the Gluon meta info for this object. This function will create an instance for the class if one does not exist.
Definition at line 760 of file gluonobject.cpp.
virtual QString GluonCore::GluonObject::name | ( | ) | const [virtual] |
Get the object's sanitized name
virtual void GluonCore::GluonObject::postCloneSanitize | ( | ) | [inline, protected, virtual] |
This function is called by the clone function before handing the cloned object back to the caller. If you have something special which needs to be done to each child after adding, re-implement this function and perform those actions.
Reimplemented in GluonEngine::GameObject.
Definition at line 351 of file gluonobject.h.
QString GluonObject::propertiesToGDL | ( | int | indentLevel = 0 |
) | const [virtual] |
Definition at line 427 of file gluonobject.cpp.
bool GluonObject::removeChild | ( | GluonObject * | child | ) | [virtual] |
Remove the passed GluonObject from the list of children on this object.
child | The child you wish to remove
|
Definition at line 379 of file gluonobject.cpp.
GluonObject * GluonObject::root | ( | ) | [virtual] |
Get the top-most GluonObject in the object hierarchy
Definition at line 350 of file gluonobject.cpp.
void GluonObject::sanitize | ( | ) | [virtual] |
Reimplemented in GluonEngine::MaterialAsset, GluonEngine::Component, and GluonEngine::GameObject.
Definition at line 143 of file gluonobject.cpp.
void GluonObject::setGameProject | ( | GluonObject * | newGameProject | ) |
Do not use this function unless you are absolutely sure what you are doing!
newGameProject | The GameProject instance this GluonObject can be found underneath |
Definition at line 239 of file gluonobject.cpp.
void GluonObject::setName | ( | const QString & | newName | ) | [virtual] |
Set a new name for the object. See also the property description.
newName | The requested new name for this object |
Reimplemented in GluonEngine::Asset, GluonEngine::MaterialAsset, GluonEngine::TextureAsset, and GluonEngine::Scene.
Definition at line 266 of file gluonobject.cpp.
void GluonObject::setPropertyFromString | ( | const QString & | propertyName, | |
const QString & | propertyValue | |||
) | [virtual] |
Definition at line 466 of file gluonobject.cpp.
Q_SIGNAL void GluonCore::GluonObject::showDebug | ( | const QString & | debugText | ) | const |
Signal which is emitted whenever a debug statement is produced using the debug() function
debugText | The debug message test |
QString GluonObject::stringFromProperty | ( | const QString & | propertyName, | |
const QString & | indentChars | |||
) | const [virtual] |
Reimplemented in GluonEngine::Component.
Definition at line 584 of file gluonobject.cpp.
const QStringList GluonObject::supportedMimeTypes | ( | ) | const [virtual] |
Used by GluonObjectFactory when requesting an object which supports a specific mimetype. The default implementation returns an empty list.
This is primarily useful for GluonEngine::Asset but other classes can potentially use it as well.
Reimplemented in GluonEngine::SoundAsset, GluonEngine::MaterialAsset, GluonEngine::TextureAsset, GluonEngine::ScriptAsset, and GluonEngine::ScriptingAsset.
Definition at line 259 of file gluonobject.cpp.
QString GluonObject::toGDL | ( | int | indentLevel = 0 |
) | const [virtual] |
Do we need the parsing code in the GluonObject? Or can we separate this into a parser class? We need to separate this into a parser class, imo. Can wait until post-alpha though. -ahiemstra
Definition at line 386 of file gluonobject.cpp.
QString GluonObject::name [read, write] |
The local name of the object. Setting the name will sanitize it according to the following rules:
To ensure the second rule, numbers are added until such time that the name becomes unique (setting name would result in first attempting "name", then "name 1", then "name 2" and so forth, until the name is unique).
Definition at line 147 of file gluonobject.h.