My Project
Public Member Functions | Public Attributes | List of all members
ParaScripting::ParaAttributeObject Class Reference

it represents an attribute object associated with an object. More...

#include <ParaScriptingGlobal.h>

Public Member Functions

 ParaAttributeObject (IAttributeFields *pAttribute, CAttributeClass *pAttClass)
 
 ParaAttributeObject (IAttributeFields *pAttribute)
 
ParaAttributeObject GetAttributeObject ()
 get the attribute object. More...
 
bool equals (const ParaAttributeObject &obj) const
 return true, if this object is the same as the given object.
 
ParaAttributeObject GetChild (const std::string &sName)
 get child attribute object. More...
 
ParaAttributeObject GetChildAt (int nIndex)
 
ParaAttributeObject GetChildAt2 (int nRowIndex, int nColumnIndex)
 
int GetChildCount ()
 
int GetChildCount2 (int nColumnIndex)
 
int GetColumnCount ()
 we support multi-dimensional child object. More...
 
bool AddChild (ParaAttributeObject &obj)
 add a child object
 
const ParaObjectQueryObject ()
 query object
 
const ParaUIObjectQueryUIObject ()
 
bool IsValid () const
 check if the object is valid
 
int GetClassID () const
 class ID
 
const char * GetClassName () const
 class name
 
const char * GetClassName1 () const
 
const char * GetClassDescription () const
 class description
 
void SetOrder (int order)
 Set which order fields are saved. More...
 
int GetOrder ()
 get which order fields are saved. More...
 
int GetFieldNum ()
 get the total number of field. More...
 
const char * GetFieldName (int nIndex)
 get field at the specified index. More...
 
int GetFieldIndex (const char *sFieldname)
 get field index of a given field name. More...
 
const char * GetFieldType (int nIndex)
 get the field type as string More...
 
bool IsFieldReadOnly (int nIndex)
 whether the field is read only. More...
 
const char * GetFieldSchematics (int nIndex)
 Get Field Schematics string. More...
 
const char * GetSchematicsType (int nIndex)
 parse the schema type from the schema string. More...
 
void GetSchematicsMinMax (int nIndex, float fMinIn, float fMaxIn, float &fMin, float &fMax)
 parse the schema min max value from the schema string. More...
 
object GetField (const char *sFieldname, const object &output)
 get field by name. More...
 
object GetField2 (const char *sFieldname, lua_State *L)
 
const char * GetStringField (const char *sFieldname)
 similar to GetField(). More...
 
double GetValueField (const char *sFieldname, int nIndex=0)
 similar to GetField(). More...
 
void SetField (const char *sFieldname, const object &input)
 set field by name e.g. More...
 
void SetStringField (const char *sFieldname, const char *input)
 similar to SetField(). More...
 
void SetValueField (const char *sFieldname, int nIndex, double value)
 similar to SetField(). More...
 
void CallField (const char *sFieldname)
 call field by name. More...
 
void PrintObject (const char *file)
 print attribute to file More...
 
bool ResetField (int nFieldID)
 Reset the field to its initial or default value. More...
 
bool InvokeEditor (int nFieldID, const char *sParameters)
 Invoke an (external) editor for a given field. More...
 
object GetDynamicField (const char *sFieldname, const object &output)
 get field by name. More...
 
object GetDynamicField_ (int nIndex, const object &output)
 Get a dynamic field with a given index.
 
object GetDynamicFieldImp (CDynamicAttributeField *pField, const object &output)
 
const char * GetDynamicFieldNameByIndex (int nIndex)
 get field name by index
 
int GetDynamicFieldCount ()
 how many dynamic field this object currently have. More...
 
int SetDynamicField (const char *sFieldname, const object &input)
 set field by name e.g. More...
 
int SetDynamicField_ (int nFieldIndex, const object &input)
 
int GetFieldKeyNums (const char *sFieldname)
 
void SetFieldKeyNums (const char *sFieldname, int nKeyNum)
 
void SetFieldKeyTime (const char *sFieldname, int nKeyIndex, int nTime)
 
int GetFieldKeyTime (const char *sFieldname, int nKeyIndex)
 
void SetFieldKeyValue (const char *sFieldname, int nKeyIndex, const object &input)
 
object GetFieldKeyValue (const char *sFieldname, int nKeyIndex, const object &output)
 
void RemoveAllDynamicFields ()
 remove all dynamic fields
 
int AddDynamicField (const std::string &sName, int dwType)
 add dynamic field and return field index More...
 

Public Attributes

IAttributeFields::WeakPtr_type m_pAttribute
 
CAttributeClassm_pAttClass
 

Detailed Description

it represents an attribute object associated with an object.

Call ParaObject::GetAttributeObject() or ParaObject::GetAttributeObject() to get an instance of this object. e.g. In NPL, one can write local att = player:GetAttributeObject(); local bGloble = att:GetField("global", true); local facing = att:GetField("facing", 0); att:SetField("facing", facing+3.14); local pos = att:GetField("position", {0,0,0}); pos[1] = pos[1]+100;pos[2] = 0;pos[3] = 10; att:SetField("position", pos); att:PrintObject("test.txt");

the following shows objects and their supported attributes.

Member Function Documentation

§ AddDynamicField()

int ParaScripting::ParaAttributeObject::AddDynamicField ( const std::string &  sName,
int  dwType 
)

add dynamic field and return field index

Parameters
dwTypetype of ATTRIBUTE_FIELDTYPE

§ CallField()

void ParaAttributeObject::CallField ( const char *  sFieldname)

call field by name.

This function is only valid when The field type is void. It simply calls the function associated with the field name.

§ GetAttributeObject()

ParaAttributeObject ParaAttributeObject::GetAttributeObject ( )

get the attribute object.

This function return a clone of this object.

§ GetChild()

ParaScripting::ParaAttributeObject ParaScripting::ParaAttributeObject::GetChild ( const std::string &  sName)

get child attribute object.

this can be regarded as an intrusive data model of a given object. once you get an attribute object, you can use this model class to access all data in the hierarchy.

§ GetColumnCount()

int ParaScripting::ParaAttributeObject::GetColumnCount ( )

we support multi-dimensional child object.

by default objects have only one column.

§ GetDynamicField()

object ParaScripting::ParaAttributeObject::GetDynamicField ( const char *  sFieldname,
const object output 
)

get field by name.

e.g. suppose att is the attribute object. local bGloble = att:GetField("URL", nil); local facing = att:GetField("Title", "default one");

Parameters
sFieldnamefield name
outputdefault value. if field type is vectorN, output is a table with N items.
Returns
: return the field result. If field not found, output will be returned. if field type is vectorN, return a table with N items.Please note table index start from 1

§ GetDynamicFieldCount()

int ParaScripting::ParaAttributeObject::GetDynamicFieldCount ( )

how many dynamic field this object currently have.

§ GetField()

object ParaAttributeObject::GetField ( const char *  sFieldname,
const object output 
)

get field by name.

e.g. suppose att is the attribute object. local bGloble = att:GetField("global", true); local facing = att:GetField("facing", 0); local pos = att:GetField("position", {0,0,0}); pos[1] = pos[1]+100;pos[2] = 0;pos[3] = 10;

Parameters
sFieldnamefield name
outputdefault value. if field type is vectorN, output is a table with N items.
Returns
: return the field result. If field not found, output will be returned. if field type is vectorN, return a table with N items.Please note table index start from 1

§ GetFieldIndex()

int ParaAttributeObject::GetFieldIndex ( const char *  sFieldname)

get field index of a given field name.

-1 will be returned if name not found.

Parameters
sFieldname
Returns

§ GetFieldName()

const char * ParaAttributeObject::GetFieldName ( int  nIndex)

get field at the specified index.

"" will be returned if index is out of range.

§ GetFieldNum()

int ParaAttributeObject::GetFieldNum ( )

get the total number of field.

§ GetFieldSchematics()

const char * ParaAttributeObject::GetFieldSchematics ( int  nIndex)

Get Field Schematics string.

Parameters
nIndexindex of the field
Returns
"" will be returned if index is out of range

§ GetFieldType()

const char * ParaAttributeObject::GetFieldType ( int  nIndex)

get the field type as string

Parameters
nIndex: index of the field
Returns
one of the following type may be returned "void" "bool" "string" "int" "float" "float_float" "float_float_float" "double" "vector2" "vector3" "vector4" "enum" "deprecated" ""

§ GetOrder()

int ParaAttributeObject::GetOrder ( )

get which order fields are saved.

§ GetSchematicsMinMax()

void ParaAttributeObject::GetSchematicsMinMax ( int  nIndex,
float  fMinIn,
float  fMaxIn,
float &  fMin,
float &  fMax 
)

parse the schema min max value from the schema string.

Parameters
nIndexindex of the field
fMin: [in|out] default value
fMax: [in|out] default value
Returns
true if found min max.

§ GetSchematicsType()

const char * ParaAttributeObject::GetSchematicsType ( int  nIndex)

parse the schema type from the schema string.

Returns
: simple schema type. it may be any of the following value. unspecified: "" color3 ":rgb" file ":file" script ":script" integer ":int"

§ GetStringField()

const char * ParaAttributeObject::GetStringField ( const char *  sFieldname)

similar to GetField().

except that the output is a string. Used for API exporting. not thread safe.

§ GetValueField()

double ParaAttributeObject::GetValueField ( const char *  sFieldname,
int  nIndex = 0 
)

similar to GetField().

except that the output is a value. Used for API exporting. not thread safe.

Parameters
nIndexif the value has multiple component, such as a vector3. this is the index of the componet.

§ InvokeEditor()

bool ParaAttributeObject::InvokeEditor ( int  nFieldID,
const char *  sParameters 
)

Invoke an (external) editor for a given field.

This is usually for NPL script field

Parameters
nFieldID: field ID
sParameters: the parameter passed to the editor
Returns
true if editor is invoked, false if failed or field has no editor.

§ IsFieldReadOnly()

bool ParaAttributeObject::IsFieldReadOnly ( int  nIndex)

whether the field is read only.

a field is ready only if and only if it has only a get method.

Parameters
nIndex: index of the field
Returns
true if it is ready only or field does not exist

§ PrintObject()

void ParaAttributeObject::PrintObject ( const char *  file)

print attribute to file

Parameters
filefile name to save the manual to.

§ ResetField()

bool ParaAttributeObject::ResetField ( int  nFieldID)

Reset the field to its initial or default value.

Parameters
nFieldID: field ID
Returns
true if value is set; false if value not set.

§ SetDynamicField()

int ParaScripting::ParaAttributeObject::SetDynamicField ( const char *  sFieldname,
const object input 
)

set field by name e.g.

suppose att is the attribute object. att:SetDynamicField("URL", 3.14); att:SetDynamicField("Title", {100,0,0});

Parameters
sFieldnamefield name
inputinput value. can be value or string type
Returns
: -1 failed, if 0 means modified, if 1 means a new key is added, if 2 means a key is removed.

§ SetField()

void ParaAttributeObject::SetField ( const char *  sFieldname,
const object input 
)

set field by name e.g.

suppose att is the attribute object. att:SetField("facing", 3.14); att:SetField("position", {100,0,0});

Parameters
sFieldnamefield name
inputinput value. if field type is vectorN, input is a table with N items.

§ SetOrder()

void ParaAttributeObject::SetOrder ( int  order)

Set which order fields are saved.

enum Field_Order { Sort_ByName, Sort_ByCategory, Sort_ByInstallOrder, };

§ SetStringField()

void ParaAttributeObject::SetStringField ( const char *  sFieldname,
const char *  input 
)

similar to SetField().

except that the input is a string. Used for API exporting. not thread safe.

§ SetValueField()

void ParaAttributeObject::SetValueField ( const char *  sFieldname,
int  nIndex,
double  value 
)

similar to SetField().

except that the input is a string. Used for API exporting. not thread safe.

Parameters
nIndexif the value has multiple component, such as a vector3. this is the index of the component.

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