GluonCore::GluonObject Class Reference

Convenience-extended version of QObjects for use with Gluon. More...

#include <gluonobject.h>

Inheritance diagram for GluonCore::GluonObject:
QObject GluonEngine::Asset GluonEngine::Component GluonEngine::GameObject GluonEngine::GameProject GluonEngine::Prefab GluonGraphics::Material GluonGraphics::MaterialElement GluonGraphics::MaterialInstance GluonGraphics::Technique

List of all members.

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 GluonObjectclone () const
Q_INVOKABLE GluonObjectclone (GluonObject *parentObject) const
virtual QString name () const
virtual void setName (const QString &newName)
QString fullyQualifiedName () const
QString fullyQualifiedFileName () const
virtual const QStringList supportedMimeTypes () const
GluonObjectgameProject () const
void setGameProject (GluonObject *newGameProject)
Q_INVOKABLE MetaInfometaInfo ()
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 GluonObjectfindItemByName (QString qualifiedName)
virtual Q_INVOKABLE GluonObjectroot ()
virtual void addChild (GluonObject *child)
virtual bool removeChild (GluonObject *child)
virtual GluonObjectchild (int index) const
virtual GluonObjectchild (const QString &name) const

Protected Member Functions

virtual void postCloneSanitize ()

Static Protected Member Functions

static GluonObjectfindItemByNameInObject (QStringList qualifiedName, GluonCore::GluonObject *object)

Properties

QString name

Detailed Description

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.


Constructor & Destructor Documentation

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.


Member Function Documentation

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

Parameters:
child The new child
See also:
name

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

Parameters:
name The name of the child you wish to fetch
Returns:
The child with the passed name, or null if no child exists by that name

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

Parameters:
index The index of the child you wish to fetch
Returns:
The child at that index, or null if the index is invalid

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

Returns:
A deep copy of the object and all its children

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.

Returns:
A deep copy of the object and all its children

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.

Parameters:
debugText The message you wish to write out
Parameters:
arg The argument of debugText. Ssee QString::arg() for more information.

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.

Parameters:
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()

Parameters:
qualifiedName The path (with object names separated by the / symbol) to the object, relative to the object this function is called on
Returns:
The object if found, or null if not

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.

Parameters:
qualifiedName The qualified name of the object you wish to locate
Parameters:
object The object to start the search at
Returns:
The object if found, or null if the object was not found

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

Returns:
A version of the fully qualified object name suitable for a file name
See also:
fullyQualifiedName()

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.

Returns:
The instance of GameProject this GluonObject is associated with. Note that it is returned as GluonObject so you will need to use a qobject_cast to cast it.
See also:
GameProject GameProject::findItemByName

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.

Returns:
True if a MetaInfo instance exists for the class

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.

Returns:
The meta information related to this object

Definition at line 760 of file gluonobject.cpp.

virtual QString GluonCore::GluonObject::name (  )  const [virtual]

Get the object's sanitized name

Returns:
The object's 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.

Parameters:
child The child you wish to remove
Returns:
True if the child was removed successfully, false if the child did not exist in this object

Definition at line 379 of file gluonobject.cpp.

GluonObject * GluonObject::root (  )  [virtual]

Get the top-most GluonObject in the object hierarchy

Returns:
The root of the GluonObject hierarchy

Definition at line 350 of file gluonobject.cpp.

void GluonObject::sanitize (  )  [virtual]
void GluonObject::setGameProject ( GluonObject newGameProject  ) 

Do not use this function unless you are absolutely sure what you are doing!

Note:
This should probably be private and make use of friend classes...
Parameters:
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.

Parameters:
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

Parameters:
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.

Returns:
A list of strings each describing a mimetype the class supports

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.


Property Documentation

QString GluonObject::name [read, write]

The local name of the object. Setting the name will sanitize it according to the following rules:

  • Names cannot contain the / symbol
    • Two objects on the same parent cannot have the same name

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.


The documentation for this class was generated from the following files:
Generated on Mon Dec 27 13:13:42 2010 for Gluon by  doxygen 1.6.3