#include <QoreClass.h>
Public Member Functions | |
DLLEXPORT | QoreClass (const char *n_name, int n_domain=QDOM_DEFAULT) |
creates the QoreClass object and assigns the name and the functional domain | |
DLLEXPORT | ~QoreClass () |
deletes the object and frees all memory | |
DLLEXPORT void | addMethod (const char *n_name, q_method_t meth, bool priv=false) |
adds a builtin method to a class | |
DLLEXPORT void | addMethod2 (const char *n_name, q_method2_t meth, bool priv=false) |
adds a builtin method with the new generic calling convention | |
DLLEXPORT void | addStaticMethod (const char *n_name, q_func_t meth, bool priv=false) |
adds a builtin static method to a class | |
DLLEXPORT void | addStaticMethod2 (const char *n_name, q_static_method2_t meth, bool priv=false) |
adds a builtin static method with the new generic calling convention | |
DLLEXPORT void | setDestructor (q_destructor_t m) |
sets the builtin destructor method for the class | |
DLLEXPORT void | setDestructor2 (q_destructor2_t m) |
sets the builtin destructor method for the class with the new generic calling convention | |
DLLEXPORT void | setConstructor (q_constructor_t m) |
sets the builtin constructor method for the class | |
DLLEXPORT void | setConstructor2 (q_constructor2_t m) |
sets the builtin constructor method for the class using the new calling convention | |
DLLEXPORT void | setSystemConstructor (q_system_constructor_t m) |
sets the builtin constructor for system objects (ex: used as constant values) | |
DLLEXPORT void | setSystemConstructor2 (q_system_constructor2_t m) |
sets the builtin constructor for system objects (ex: used as constant values) using the new calling convention | |
DLLEXPORT void | setCopy (q_copy_t m) |
sets the builtin copy method for the class | |
DLLEXPORT void | setCopy2 (q_copy2_t m) |
sets the builtin copy method for the class using the new generic calling convention | |
DLLEXPORT void | setDeleteBlocker (q_delete_blocker_t m) |
sets the deleteBlocker method for the class | |
DLLEXPORT void | addPrivateMember (char *name) |
adds a name of a private member (not accessible from outside the class hierarchy) | |
DLLEXPORT bool | isPrivateMember (const char *str) const |
returns true if the member is private | |
DLLEXPORT QoreObject * | execConstructor (const QoreListNode *args, ExceptionSink *xsink) const |
creates a new object and executes the constructor on it and returns the new object | |
DLLEXPORT QoreObject * | execSystemConstructor (int code=0,...) const |
creates a new "system" object for use as the value of a constant, executes the system constructor on it and returns the new object | |
DLLEXPORT QoreObject * | execCopy (QoreObject *old, ExceptionSink *xsink) const |
executes a class' "copy" method on an object and returns the new object (or 0 in the case of an exception) | |
DLLEXPORT const QoreMethod * | findLocalMethod (const char *name) const |
looks for a non-static method in the current class without searching base classes | |
DLLEXPORT const QoreMethod * | findLocalStaticMethod (const char *name) const |
looks for a static method in the current class without searching base classes | |
DLLEXPORT QoreListNode * | getMethodList () const |
returns a list strings of all non-static methods in the class, the caller owns the reference count returned | |
DLLEXPORT QoreListNode * | getStaticMethodList () const |
returns a list strings of all static methods in the class, the caller owns the reference count returned | |
DLLEXPORT QoreClass * | getClass (qore_classid_t cid) const |
returns a pointer to the QoreClass object representing the class ID passed if it exists in the class hierarchy | |
DLLEXPORT int | numMethods () const |
returns the number of non-static methods in this class (user and builtin) | |
DLLEXPORT int | numStaticMethods () const |
returns the number of static methods in this class (user and builtin) | |
DLLEXPORT int | numUserMethods () const |
returns the number of non-static user methods in this class | |
DLLEXPORT int | numStaticUserMethods () const |
returns the number of static user methods in this class | |
DLLEXPORT bool | hasCopy () const |
returns true if the class implements a copy method | |
DLLEXPORT qore_classid_t | getID () const |
returns the class ID of this class | |
DLLEXPORT bool | isSystem () const |
returns true if the class is a builtin class | |
DLLEXPORT bool | hasMemberGate () const |
returns true if the class implements a "memberGate" method | |
DLLEXPORT bool | hasMemberNotification () const |
returns true if the class implements a "memberNotification" method | |
DLLEXPORT int | getDomain () const |
returns the functional domain of the class | |
DLLEXPORT const char * | getName () const |
returns the class name | |
DLLEXPORT const QoreMethod * | findMethod (const char *nme) const |
finds a non-static method in the class hierarchy | |
DLLEXPORT const QoreMethod * | findStaticMethod (const char *nme) const |
finds a static method in the class hierarchy | |
DLLEXPORT const QoreMethod * | findMethod (const char *nme, bool &priv) const |
finds a non-static method in the class hierarchy and sets the priv flag if it's a private method or not | |
DLLEXPORT const QoreMethod * | findStaticMethod (const char *nme, bool &priv) const |
finds a static method in the class hierarchy and sets the priv flag if it's a private method or not | |
DLLEXPORT void | addBuiltinBaseClass (QoreClass *qc, class QoreListNode *xargs=0) |
make a builtin class a child of another builtin class | |
DLLEXPORT void | addDefaultBuiltinBaseClass (QoreClass *qc, class QoreListNode *xargs=0) |
make a builtin class a child of another builtin class and ensures that the given class' private data will be used in all class methods | |
DLLEXPORT void | addBuiltinVirtualBaseClass (QoreClass *qc) |
sets "virtual" base class for a class, meaning that the base class data is appropriate for use in the subclass builtin methods | |
DLLEXPORT void | setSynchronousClass () |
call this function if your builtin class requires *all* methods (except the constructor) to be run in an RMutex lock | |
DLLEXPORT const QoreMethod * | getConstructor () const |
returns a const pointer to the QoreMethod object of the constuctor method, if any is set | |
DLLEXPORT const QoreMethod * | getSystemConstructor () const |
returns a const pointer to the QoreMethod object of the constuctor method, if any is set | |
DLLEXPORT const QoreMethod * | getDestructor () const |
returns a const pointer to the QoreMethod object of the constructor method, if any is set | |
DLLEXPORT const QoreMethod * | getCopyMethod () const |
returns a const pointer to the QoreMethod object of the destructor method, if any is set | |
DLLEXPORT const QoreMethod * | getMemberGateMethod () const |
returns a const pointer to the QoreMethod object of the memberGate method, if any is set | |
DLLEXPORT const QoreMethod * | getMethodGate () const |
returns a const pointer to the QoreMethod object of the methodGate method, if any is set | |
DLLEXPORT const QoreMethod * | getMemberNotificationMethod () const |
returns a const pointer to the QoreMethod object of the memberNotification method, if any is set | |
Friends | |
class | QoreObject |
Qore's classes can be either implemented by Qore language code (user classes) or in C++ (builtin classes), or both, as in the case of a builtin class that also has user methods.
DLLEXPORT QoreClass::QoreClass | ( | const char * | n_name, | |
int | n_domain = QDOM_DEFAULT | |||
) |
creates the QoreClass object and assigns the name and the functional domain
n_name | the name of the class | |
n_domain | the functional domain of the class to be used to enforce functional restrictions within a Program object |
DLLEXPORT void QoreClass::addBuiltinBaseClass | ( | QoreClass * | qc, | |
class QoreListNode * | xargs = 0 | |||
) |
make a builtin class a child of another builtin class
Private inheritance makes no sense with builtin classes (there would be too much overhead to use user-level qore interfaces to call private methods) but base class constructor arguments can be given. This function takes over ownership for the reference for the xargs pointer argument
qc | the base class to add | |
xargs | the argument expression for the base class constructor call |
DLLEXPORT void QoreClass::addBuiltinVirtualBaseClass | ( | QoreClass * | qc | ) |
sets "virtual" base class for a class, meaning that the base class data is appropriate for use in the subclass builtin methods
this method adds a base class placeholder for a subclass - where the subclass' private data object is actually a subclass of the parent class and all methods are virtual, so the base class' constructor, destructor, and copy constructor will never be run and the base class methods will be passed a pointer to the subclass' data
qc | the base class to add |
DLLEXPORT void QoreClass::addDefaultBuiltinBaseClass | ( | QoreClass * | qc, | |
class QoreListNode * | xargs = 0 | |||
) |
make a builtin class a child of another builtin class and ensures that the given class' private data will be used in all class methods
In the case this function is used, this objects of class cannot have private data saved against the class ID. This function takes over ownership for the reference for the xargs pointer argument
qc | the base class to add | |
xargs | the argument expression for the base class constructor call |
DLLEXPORT void QoreClass::addMethod | ( | const char * | n_name, | |
q_method_t | meth, | |||
bool | priv = false | |||
) |
adds a builtin method to a class
in debuggging mode, the call will abort if the name of the method is "constructor", "destructor", or "copy", or if the method already exists in the class. To set the constructor method, call QoreClass::setConstructor(). To set the destructor method, call QoreClass::setDestructor(). To set the copy method, call QoreClass::setCopy().
n_name | the name of the method, must be unique in the class | |
meth | the method to be added | |
priv | if true then the method will be added as a private method // the actual function can be declared with the class to be expected as the private data as follows: static AbstractQoreNode *AL_lock(QoreObject *self, QoreAutoLock *m, const QoreListNode *params, ExceptionSink *xsink); ... // and then casted to (q_method_t) in the addMethod call: QC_AutoLock->addMethod("lock", (q_method_t)AL_lock); |
DLLEXPORT void QoreClass::addPrivateMember | ( | char * | name | ) |
adds a name of a private member (not accessible from outside the class hierarchy)
this method takes ownership of *name
name | the name of the private member (ownership of the memory is assumed by the QoreClas object) |
DLLEXPORT void QoreClass::addStaticMethod | ( | const char * | n_name, | |
q_func_t | meth, | |||
bool | priv = false | |||
) |
adds a builtin static method to a class
n_name | the name of the method, must be unique in the class | |
meth | the method to be added | |
priv | if true then the method will be added as a private method |
DLLEXPORT QoreObject* QoreClass::execConstructor | ( | const QoreListNode * | args, | |
ExceptionSink * | xsink | |||
) | const |
creates a new object and executes the constructor on it and returns the new object
if a Qore-language exception occurs, 0 is returned. To create a
args | the arguments for the method | |
xsink | Qore-language exception information is added here |
DLLEXPORT QoreObject* QoreClass::execCopy | ( | QoreObject * | old, | |
ExceptionSink * | xsink | |||
) | const |
executes a class' "copy" method on an object and returns the new object (or 0 in the case of an exception)
old | the original object to copy | |
xsink | Qore-language exception information is added here |
DLLEXPORT QoreObject* QoreClass::execSystemConstructor | ( | int | code = 0 , |
|
... | ||||
) | const |
creates a new "system" object for use as the value of a constant, executes the system constructor on it and returns the new object
if a Qore-language exception occurs, 0 is returned
code | an optional code for the constructor; this parameter is here because passing a variable number of arguments requires at least one fixed parameter before the (possibly empty) list |
DLLEXPORT const QoreMethod* QoreClass::findLocalMethod | ( | const char * | name | ) | const |
looks for a non-static method in the current class without searching base classes
name | the name of the method |
DLLEXPORT const QoreMethod* QoreClass::findLocalStaticMethod | ( | const char * | name | ) | const |
looks for a static method in the current class without searching base classes
name | the name of the static method |
DLLEXPORT QoreClass* QoreClass::getClass | ( | qore_classid_t | cid | ) | const |
returns a pointer to the QoreClass object representing the class ID passed if it exists in the class hierarchy
if the class ID is equal to the current class or is a base class of the current class, the appropriate QoreClass pointer will be returned.
cid | the class ID of the QoreClass to find |
DLLEXPORT const QoreMethod* QoreClass::getConstructor | ( | ) | const |
returns a const pointer to the QoreMethod object of the constuctor method, if any is set
executes in constant time
DLLEXPORT const QoreMethod* QoreClass::getCopyMethod | ( | ) | const |
returns a const pointer to the QoreMethod object of the destructor method, if any is set
executes in constant time
DLLEXPORT const QoreMethod* QoreClass::getDestructor | ( | ) | const |
returns a const pointer to the QoreMethod object of the constructor method, if any is set
executes in constant time
DLLEXPORT const QoreMethod* QoreClass::getMemberGateMethod | ( | ) | const |
returns a const pointer to the QoreMethod object of the memberGate method, if any is set
executes in constant time
DLLEXPORT const QoreMethod* QoreClass::getMemberNotificationMethod | ( | ) | const |
returns a const pointer to the QoreMethod object of the memberNotification method, if any is set
executes in constant time
DLLEXPORT const QoreMethod* QoreClass::getMethodGate | ( | ) | const |
returns a const pointer to the QoreMethod object of the methodGate method, if any is set
executes in constant time
DLLEXPORT QoreListNode* QoreClass::getMethodList | ( | ) | const |
returns a list strings of all non-static methods in the class, the caller owns the reference count returned
always returns a list; if there are no non-static methods then an empty list is returned
DLLEXPORT QoreListNode* QoreClass::getStaticMethodList | ( | ) | const |
returns a list strings of all static methods in the class, the caller owns the reference count returned
always returns a list; if there are no static methods then an empty list is returned
DLLEXPORT const QoreMethod* QoreClass::getSystemConstructor | ( | ) | const |
returns a const pointer to the QoreMethod object of the constuctor method, if any is set
executes in constant time
DLLEXPORT bool QoreClass::isPrivateMember | ( | const char * | str | ) | const |
returns true if the member is private
str | the member name to check |
DLLEXPORT void QoreClass::setConstructor | ( | q_constructor_t | m | ) |
sets the builtin constructor method for the class
m | the constructor method |
DLLEXPORT void QoreClass::setConstructor2 | ( | q_constructor2_t | m | ) |
sets the builtin constructor method for the class using the new calling convention
m | the constructor method |
DLLEXPORT void QoreClass::setCopy | ( | q_copy_t | m | ) |
sets the builtin copy method for the class
copy methods should either call QoreObject::setPrivate() or call xsink->raiseException() (but should not do both)
m | the copy method to set // the actual function can be declared with the class to be expected as the private data as follows: static void AL_copy(QoreObject *self, QoreObject *old, class QoreAutoLock *m, ExceptionSink *xsink) ... // and then casted to (q_copy_t) in the addMethod call: QC_AutoLock->setCopy((q_copy_t)AL_copy); |
DLLEXPORT void QoreClass::setCopy2 | ( | q_copy2_t | m | ) |
sets the builtin copy method for the class using the new generic calling convention
copy methods should either call QoreObject::setPrivate() or call xsink->raiseException() (but should not do both)
m | the copy method to set // the actual function can be declared with the class to be expected as the private data as follows: static void AL_copy(const QoreClass &thisclass, QoreObject *self, QoreObject *old, QoreAutoLock *m, ExceptionSink *xsink) ... // and then casted to (q_copy2_t) in the addMethod call: QC_AutoLock->setCopy((q_copy2_t)AL_copy); |
DLLEXPORT void QoreClass::setDeleteBlocker | ( | q_delete_blocker_t | m | ) |
sets the deleteBlocker method for the class
this method will be run when the object is deleted; it should be set only for classes where the objects' lifecycles are or may be managed externally.
m | the deleteBlocker method to set |
DLLEXPORT void QoreClass::setDestructor | ( | q_destructor_t | m | ) |
sets the builtin destructor method for the class
you only need to implement destructor methods if the destructor should destroy the object before the reference count reaches zero.
m | the destructor method to run // the actual function can be declared with the class to be expected as the private data as follows: static void AL_destructor(QoreObject *self, QoreAutoLock *al, ExceptionSink *xsink); ... // and then casted to (q_destructor_t) in the addMethod call: QC_AutoLock->setDestructor((q_destructor_t)AL_destructor); |
DLLEXPORT void QoreClass::setDestructor2 | ( | q_destructor2_t | m | ) |
sets the builtin destructor method for the class with the new generic calling convention
you only need to implement destructor methods if the destructor should destroy the object before the reference count reaches zero.
m | the destructor method to run // the actual function can be declared with the class to be expected as the private data as follows: static void AL_destructor(const QoreClass &thisclass, QoreObject *self, QoreAutoLock *al, ExceptionSink *xsink); ... // and then casted to (q_destructor_t) in the addMethod call: QC_AutoLock->setDestructor2((q_destructor_t)AL_destructor); |
DLLEXPORT void QoreClass::setSynchronousClass | ( | ) |
call this function if your builtin class requires *all* methods (except the constructor) to be run in an RMutex lock
use this for classes that require exclusive access to the private data in all functions
DLLEXPORT void QoreClass::setSystemConstructor | ( | q_system_constructor_t | m | ) |
sets the builtin constructor for system objects (ex: used as constant values)
m | the constructor method |
DLLEXPORT void QoreClass::setSystemConstructor2 | ( | q_system_constructor2_t | m | ) |
sets the builtin constructor for system objects (ex: used as constant values) using the new calling convention
m | the constructor method |