HxmClass Class¶
- class Hexaly.Modeler.HxmClass¶
Each instance of an HxmClass represents a class available and loaded in a module. Each HXM object has a type represented by an HxmClass whether it comes from a builtin or a user defined class. Therefore, it is possible to retrieve the class of any value that is not a boolean, integer, double or nil.
The methods below can be used to introspect the contents of all HXM classes and, in particular, to extract the various methods, properties and fields of the class, including static fields. It is also possible to build new instances of this class using the
HxmClass.NewInstance
method.An HxmClass is itself a modeler value. In other words, an HxmClass is a first-class citizen and can be passed as a parameter to any method that expects an object or a value. Managing the lifetime of an HxmClass is the same as any other modeler object (using
HxmReferenceScope
orHxmClass.Dispose
method).Since an HxmClass is a value, each HxmClass also has a type represented by another HxmClass that describes the fundamental type of all other types.
- Since:
13.0
Summary¶
Returns a new instance of this class. |
|
Gets the full name of the class including the name of the module in which the class has been declared (e. |
|
Returns true if the class has been declared as final. |
|
Returns true if this class is a subclass of the class given as parameter. |
|
Returns true if the value passed in parameter is an instance of this class. |
|
Returns true if this class extends another class. |
|
Returns the class extended by this class. |
|
Returns the number of members present in this class. |
|
Returns the name of the member with the given id. |
|
Returns the type of the member with the given id. |
|
Returns the id of the member with the given name or -1 if no such member exists in the class. |
|
Returns true if a member with the given name is present in the class. |
|
Returns true if a method with the given name is present in the class or inherited from a parent class. |
|
Returns true if a field with the given name is present in the class or inherited from a parent class. |
|
Returns true if a property with the given name is present in the class or inherited from a parent class. |
|
Returns the method with the given id as an HxmFunction. |
|
Returns the field with the given id as an HxmField. |
|
Returns the property with the given id as an HxmProperty. |
|
Returns the number of static members declared in the class. |
|
Returns the name of the static member with the given id. |
|
Returns the id of the static member with the given name or -1 if no such member exists in the class. |
|
Returns true if a static member with the given name is declared in the class. |
|
Returns the value of the static member with the given id. |
|
Sets the value of the static member with the given id. |
|
Returns the class as an HxmValue. |
|
Releases the reference. |
Instance methods¶
- HxmValue NewInstance()¶
Returns a new instance of this class. The constructor is called with no arguments.
- Returns:
A new instance object of this class.
- Return type:
- HxmValue NewInstance(params HxmValue[] arguments)
- HxmValue NewInstance(List<HxmValue> arguments)
Returns a new instance of this class. The constructor is called with the arguments passed as parameters.
- Arguments:
arguments – List of arguments for the constructor.
- Returns:
A new instance object of this class.
- Return type:
- string GetDeclaredName()¶
Gets the full name of the class including the name of the module in which the class has been declared (e.g.
module_name.ClassName
).- Returns:
Name of the class.
- Return type:
string
- bool IsFinal()¶
Returns true if the class has been declared as final. A final class is a class that cannot be extended by inheritance.
- Returns:
True if the class is final.
- Return type:
bool
- bool IsSubClassOf(HxmClass other)¶
Returns true if this class is a subclass of the class given as parameter. To be considered a subclass, this class must inherit directly or indirectly from the class given as parameter.
- Arguments:
other (
HxmClass
) – Other class from which the inheritance will be tested.- Returns:
True if this class is a subclass of the class the given as parameter.
- Return type:
bool
- bool IsInstance(HxmValue value)¶
Returns true if the value passed in parameter is an instance of this class. An object is considered to be an instance of the class if the object’s type is equal to this class, or if the object’s type is a subclass of this class. If the value passed in parameter is not an object (such as a boolean, integer, double or nil), then false is always returned.
- Arguments:
value (
HxmValue
) – Value for which the inheritance will be tested.- Returns:
True if the given value is an instance of this class.
- Return type:
bool
- bool HasSuperClass()¶
Returns true if this class extends another class. The extended class can be retrieved with the method
GetSuperClass()
.- Returns:
True if this class extends another class.
- Return type:
bool
- HxmClass GetSuperClass()¶
Returns the class extended by this class. An exception is thrown if this class does not have a super class.
- Returns:
The class extended by this class.
- Return type:
- int GetNbMembers()¶
Returns the number of members present in this class. The members considered are those declared in this class or inherited from parent classes. A member is a field, property, method or constructor. The returned number can be used to browse members using the following methods, which take a
memberId
parameter ranging from 0 toGetNbMembers()
.- Returns:
Number of members declared in the class or in the parent classes.
- Return type:
int
- string GetMemberName(int memberId)¶
Returns the name of the member with the given id. An exception is thrown if
memberId
is less than 0 or greater than the number of members returned by the methodGetNbMembers()
.- Arguments:
memberId (
int
) – Id of the member to get the name.- Returns:
Name of the member with the given id.
- Return type:
string
- HxmMemberType GetMemberType(int memberId)¶
Returns the type of the member with the given id. An exception is thrown if
memberId
is less than 0 or greater than the number of members returned by the methodGetNbMembers()
.- Arguments:
memberId (
int
) – Id of the member to get the type.- Returns:
Type of the member with the given id.
- Return type:
- HxmMemberType GetMemberType(string memberName)
Returns the type of the member with the given name. An exception is thrown if no member with the given name is present in the class. The member name is case sensitive.
- Arguments:
memberName (
string
) – Name of the member to get the type.- Returns:
Type of the member with the given name.
- Return type:
- int FindMemberId(string memberName)¶
Returns the id of the member with the given name or -1 if no such member exists in the class. The considered members are those declared in this class or inherited from parent classes. The member name is case sensitive.
- Arguments:
memberName (
string
) – Name of the member to get the id.- Returns:
The id of the member with the given name.
- Return type:
int
- bool IsMember(string memberName)¶
Returns true if a member with the given name is present in the class. The considered members are those declared in this class or inherited from parent classes. The member name is case sensitive. This method is equivalent to
FindMemberId(memberName) != -1
.- Arguments:
memberName (
string
) – Name of the member to check.- Returns:
True if a member with the given name is present in the class.
- Return type:
bool
- bool IsMethod(string memberName)¶
Returns true if a method with the given name is present in the class or inherited from a parent class. Returns false if no method with the given name is present or if the member is not a method. The member name is case sensitive.
- Arguments:
memberName (
string
) – Name of the method to check.- Returns:
True if a method with the given name is present in the class.
- Return type:
bool
- bool IsMethod(int memberId)
Returns true if the member with the given id is a method. False is returned otherwise or an exception is thrown if
memberId
is less than 0 or greater than the number of members returned by the methodGetNbMembers()
.- Arguments:
memberId (
int
) – Id of the method to check.- Returns:
True if the member with the given id is a method.
- Return type:
bool
- bool IsField(string memberName)¶
Returns true if a field with the given name is present in the class or inherited from a parent class. Returns false if no field with the given name is present or if the member is not a field. The member name is case sensitive.
- Arguments:
memberName (
string
) – Name of the field to check.- Returns:
True if a field with the given name is present in the class.
- Return type:
bool
- bool IsField(int memberId)
Returns true if the member with the given id is a field. False is returned otherwise or an exception is thrown if
memberId
is less than 0 or greater than the number of members returned by the methodGetNbMembers()
.- Arguments:
memberId (
int
) – Id of the field to check.- Returns:
True if the member with the given id is a field.
- Return type:
bool
- bool IsProperty(string memberName)¶
Returns true if a property with the given name is present in the class or inherited from a parent class. Returns false if no property with the given name is present or if the member is not a property. The member name is case sensitive.
- Arguments:
memberName (
string
) – Name of the property to check.- Returns:
True if a property with the given name is present in the class.
- Return type:
bool
- bool IsProperty(int memberId)
Returns true if the member with the given id is a property. False is returned otherwise or an exception is thrown if
memberId
is less than 0 or greater than the number of members returned by the methodGetNbMembers()
.- Arguments:
memberId (
int
) – Id of the property to check.- Returns:
True if the member with the given id is a property.
- Return type:
bool
- HxmFunction GetMethod(int memberId)¶
Returns the method with the given id as an
HxmFunction
. An exception is thrown if the member is not a method or ifmemberId
is less than 0 or greater than the number of members returned by the methodGetNbMembers()
.Once the method has been retrieved as a
HxmFunction
, you can call it withHxmFunction.CallThis()
by passing an object of this class as the first argument.- Arguments:
memberId (
int
) – Id of the method to get.- Returns:
The method with the given id.
- Return type:
- HxmFunction GetMethod(string memberName)
Returns the method with the given name as an
HxmFunction
. An exception is thrown if the member is not a method or if no member with the given name is present in the class. The member name is case sensitive.Once the method has been retrieved as a
HxmFunction
, you can call it withHxmFunction.CallThis()
by passing an object of this class as the first argument.- Arguments:
memberName (
string
) – Name of the method to get.- Returns:
The method with the given name.
- Return type:
- HxmField GetField(int memberId)¶
Returns the field with the given id as an
HxmField
. An exception is thrown if the member is not a field or ifmemberId
is less than 0 or greater than the number of members returned by the methodGetNbMembers()
.Once the field has been retrieved as a
HxmField
, you can retrieve or modify the value of the field for any object of this class using the various get and set methods likeHxmField.GetValue()
.- Arguments:
memberId (
int
) – Id of the member to get.- Returns:
The field with the given id.
- Return type:
- HxmField GetField(string memberName)
Returns the field with the given name as an
HxmField
. An exception is thrown if the member is not a field or if no member with the given name is present in the class. The member name is case sensitive.Once the field has been retrieved as a
HxmField
, you can retrieve or modify the value of the field for any object of this class using the various get and set methods likeHxmField.GetValue()
.- Arguments:
memberName (
string
) – Name of the field to get.- Returns:
The field with the given name.
- Return type:
- HxmProperty GetProperty(int memberId)¶
Returns the property with the given id as an
HxmProperty
. An exception is thrown if the member is not a property or ifmemberId
is less than 0 or greater than the number of members returned by the methodGetNbMembers()
.Once the property has been retrieved as a
HxmProperty
, you can retrieve or modify the value of the property for any object of this class using the various get and set methods likeHxmProperty.GetValue()
.- Arguments:
memberId (
int
) – Id of the member to get.- Returns:
The property with the given id.
- Return type:
- HxmProperty GetProperty(string memberName)
Returns the property with the given name as an
HxmProperty
. An exception is thrown if the member is not a property or if no member with the given name is present in the class. The member name is case sensitive.Once the property has been retrieved as a
HxmProperty
, you can retrieve or modify the value of the property for any object of this class using the various get and set methods likeHxmProperty.GetValue()
.- Arguments:
memberName (
string
) – Name of the property to get.- Returns:
The property with the given name.
- Return type:
- int GetNbStaticMembers()¶
Returns the number of static members declared in the class. Only the static members declared specfically in this class actually count. There is no inheritance for static members and therefore parent classes are ignored. The returned number can be used to browse static members using the following methods, which take a
staticMemberId
parameter ranging from 0 toGetNbStaticMembers()
.- Returns:
Number of static members declared in this class
- Return type:
int
- string GetStaticMemberName(int staticMemberId)¶
Returns the name of the static member with the given id. An exception is thrown if
staticMemberId
is less than 0 or greater than the number of static members returned by the methodGetNbStaticMembers()
.- Arguments:
staticMemberId (
int
) – Id of the static member to get.- Returns:
Name of the member with the given id.
- Return type:
string
- int FindStaticMemberId(string staticMemberName)¶
Returns the id of the static member with the given name or -1 if no such member exists in the class. Only the static members declared specfically in this class are actually considered for the search. The static member name is case sensitive.
- Arguments:
staticMemberName (
string
) – Name of the static member to get the id.- Returns:
The id of the static member with the given name.
- Return type:
int
- bool IsStaticMember(string staticMemberName)¶
Returns true if a static member with the given name is declared in the class. The considered static members are only those specifically declared in the current class. There is no inheritance for static members, therefore parent classes are ignored in the search. The static member name is case sensitive.
- Arguments:
staticMemberName (
string
) – Name of the static member to check.- Returns:
True if a static member with the given name is declared in the class.
- Return type:
bool
- HxmValue GetStaticMember(int staticMemberId)¶
Returns the value of the static member with the given id. An exception is thrown if
staticMemberId
is less than 0 or greater than the number of static members returned by the methodGetNbStaticMembers()
.- Arguments:
staticMemberId (
int
) – Id of the static member to get.- Returns:
Value of the static member with the given id.
- Return type:
- HxmValue GetStaticMember(string staticMemberName)
Returns the value of the static member with the given name. An exception is thrown if no static member with the given name is present in the class. The static member name is case sensitive.
- Arguments:
staticMemberName (
string
) – Name of the static member to get.- Returns:
Value of the static member with the given name.
- Return type:
- void SetStaticMember(int staticMemberId, HxmValue value)¶
Sets the value of the static member with the given id. An exception is thrown if
staticMemberId
is less than 0 or greater than the number of static members returned by the methodGetNbStaticMembers()
.- Arguments:
staticMemberId (
int
) – Id of the static member to set.value (
HxmValue
) – Value of the static member to set.
- void SetStaticMember(string staticMemberName, HxmValue value)
Sets the value of the static member with the given id. An exception is thrown if no static member with the given name is present in the class. The static member name is case sensitive.
- Arguments:
staticMemberName (
string
) – Name of the static member to set.value (
HxmValue
) – Value of the static member to set.
- HxmValue AsValue()¶
Returns the class as an
HxmValue
.- Returns:
The class as an HxmValue.
- Return type:
- void Dispose()¶
Releases the reference. If this value was already released, returns immediately and does nothing. Invoking any method on this object after this operation will throw an exception.
Note: Releasing a reference does not necessarily imply that the underlying value object is destroyed. It is only destroyed if no more references point to it.