Object Methods and Fields

brefs

obj.brefs

Description

This field corresponds to a table that can be used for retrieving the back-references of an inmation object. Each entry in this table is in itself a table, corresponding to one reference. Each reference has three fields: name, path, and type. Check syslib.getbackreferences() function for a list of all the existing types.

Examples

The following is an example how back-references of an existing object can be retrieved:

local obj = syslib.getobject("/System/Core/object")
return obj.brefs
The back-references table and its sub-tables are read-only tables. Any attempt to add new entries to them will result in an error. Any alternation to their existing fields will get ignored when calling obj:commit(). To alter back-references of an object, use obj.refs or syslib.setreferences() on the referencing objects.
The first time this field is accessed, it captures the state of the object back-references. Afterwards, any updates to the back-references of the object will not be reflected upon subsequent accesses.

cfgversion

obj:cfgversion()

Description

Returns the configuration version of the object.

Examples

obj = syslib.getobject("/System/Core/object")
configversion = obj:cfgversion()

child

obj:child()

Description

Takes the name of a child (a.k.a. the ObjectName property) and returns it as an inmation object. It returns nil if the named child does not exist.

Examples

obj = syslib.getobject("/System/localhost/object")
child = obj:child("child1")

children

obj:children()

Description

Returns a table containing all the direct children as inmation objects.

Examples

obj = syslib.getobject("/System/localhost/object")
children = obj:children()
paths = {}
for _,c in pairs(children) do
    table.insert(paths, c:path())
end
return paths

classversion

obj:classversion()

Description

Returns the class version of the object (e.g. "2.568").

Examples

obj = syslib.getobject("/System/CORE/object")
classversion = obj:classversion()

comm_empty

obj:comm_empty()

Description

Returns true if the communication state of the object is "empty", will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

comm_error

obj:comm_error()

Description

Returns true if the communication state of the object is "error", will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

comm_good

obj:comm_good()

Description

Returns true if the communication state of the object is "good", will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

comm_neutral

obj:comm_neutral()

Description

Returns true if the communication state of the object is "neutral", will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

comm_warning

obj:comm_warning()

Description

Returns true if the communication state of the object is "warning", will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

classmismatch

obj:classmismatch()

Description

Returns true if the local and remote class versions mismatch, will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

commit

obj:commit()

Description

See the examples for the functions syslib.createobject() and syslib.getobject().

created

obj:created()

Description

Returns three values related to object creation information:

  • the UTC timestamp (as posix time) representing the moment of creation

  • the means of creation (e.g. "system", "gui")

  • the account used to create the object (e.g. "DOMAINNAME/USERNAME")

deleted

obj:deleted()

Description

Returns true if the object is deleted, will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

dynamic

obj:dynamic()

Description

Returns true if the object has dynamic properties, will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

empty

obj:empty()

Description

Returns true if the state of the object is "empty", will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

enabled

obj:enabled()

Description

Returns true if the object is enabled, will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

error

obj:error()

Description

Returns true if the state of the object is "error", will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

exploring

obj:exploring()

Description

Returns true if the object is exploring, will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

good

obj:good()

Description

Returns true if the state of the object is "good", will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

has_objref

obj:has_objref()

Description

Returns true if the object has object references, will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

has_secref

obj:has_secref()

Description

Returns true if the object has security references, will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

modified

obj:modified()

Description

Returns the same three values as the created method does, only that they concern last modification information.

neutral

obj:neutral()

Description

Returns true if the state of the object is "neutral", will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

numid

obj:numid()

Description

Returns the numerical ID of the object (e.g. 281475465543680).

parent

obj:parent()

Description

Returns the parent of an object as an inmation object.

Examples

obj = syslib.getobject("/System/localhost/object")
parent = obj:parent()
return parent:path()

path

obj:path()

Description

Returns the path of an inmation object.

Examples

obj = syslib.getobject("/System/localhost/object")
path = obj:path()

refs

obj.refs

Description

This is a field corresponding to a table that can be used for creating and modifying the references of an inmation object. Each entry in this table is itself a table, corresponding to one reference. Each reference has three fields: name, path, and type. Only the path field is mandatory.

Examples

The following is an example how references can be set on a new object:

local a = syslib.createobject("/System/localhost", "MODEL_CLASS_ACTIONITEM")
a.ObjectName = "new"
a.AdvancedLuaScript = "return syslib.getvalue('A')"
a.refs = { { name = 'A', path = syslib.slf():path() } }
a:commit()
return 'OK'

This will create an action item with a reference to self named A. The type, when not specified, defaults to "OBJECT_LINK" (triggering). Check the syslib.setreferences() function for a list of all the existing types. The following example shows how to modify existing references – delete all of them in this case – and also inspect what references are present:

local a = syslib.getobject("/System/localhost/new")
local old = a.refs
a.refs = {}
a:commit()
return old[1].path

When a refs field is set, as in the examples above, it must be set to a table; setting it to anything else, including nil, will make the object not-committable. The same applies to the content of refs table: it must only contain tables, and those in turn must contain at least the path field.

It is also possible not to set or reset the entire refs table as in the examples above, but manipulate individual entries directly, via a.refs[1] = … or via a.refs[1].path = …
The first time this field is accessed, it captures the state of the object references. Afterwards, any updates to the references of the object will not be reflected upon subsequent accesses.

registering

obj:registering()

Description

Returns true if the object is registering, will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

sysname

obj:sysname()

Description

Returns the system name (e.g. "CO.1.13").

state

obj:state()

Description

Returns the Object State bitmask as an integer. See the ModObjectState flag group for more details.

textid

obj:textid()

Description

Returns the textual ID of the object (e.g. "1.7459.0").

type

obj:type()

Description

Determines the object’s class. It returns two values as follows: first is the string value of the type (e.g. "MODEL_CLASS_CORE") and the second is the numeric value of the type (e.g. 3 for a Core object).

Examples

obj = syslib.getobject("/System/localhost/object")
type_meaning, type_code = obj:type()

unconfirmed

obj:unconfirmed()

Description

Returns true if the state of the object is "unconfirmed", will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.

warning

obj:warning()

Description

Returns true if the state of the object is "warning", will return false if not. Corresponds to the ModUserState flag mask that indicates the direct colour state of objects in the UI.