#include <coherence/lang/Method.hpp>
Inherits AnnotatedElement.
Inherited by TypedMethod.
To be of general use these Methods must also be registered with the corresponding Class object during Class registration. Once registered the Method can be found at runtime as follows:
Method::View vMethodName = SystemClassLoader::getInstance() ->loadByName("Person")->getMethod("getName");
And then finally applied:
Object::View vo = getPersonFromSomewhere(); std::cout << vMethodName->invoke(vo) << std::endl;
Public Types | ||||
enum | Modifier { modifier_instance, modifier_static, modifier_mutable, modifier_const } | |||
Modifier defines the various reflectable Method modifiers. More... | ||||
typedef spec::Handle | Handle | |||
Method Handle definition. | ||||
typedef spec::View | View | |||
Method View definition. | ||||
typedef spec::Holder | Holder | |||
Method Holder definition. | ||||
typedef TypedHandle < const Class > | ClassView | |||
Forward declaration of Class::View. | ||||
Public Member Functions | ||||
virtual String::View | getName () const | |||
Return the method name. | ||||
virtual int32_t | getModifiers () const =0 | |||
Return the method modifiers. | ||||
virtual ObjectArray::View | getParameterTypes () const =0 | |||
Return an array of Class::Views representing the method parameter types. | ||||
virtual ClassView | getReturnType () const =0 | |||
Return the Class::View representing the method's return type, or NULL for void. | ||||
virtual ClassView | getDeclaringClass () const =0 | |||
Return the Class::View representing the class in which the method is declared. | ||||
virtual Object::Holder | invoke (Object::Holder oh, ObjectArray::View vaArgs=NULL) const =0 | |||
Execute the method. | ||||
virtual Method::Handle | annotate (Annotation::View vAnnontation) | |||
Add the specified Annotation to the element. | ||||
virtual void | toStream (std::ostream &out) const | |||
Output a human-readable description of this Object to the given stream. coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toStream method, to output Objects. If a managed String object is desired, the COH_TO_STRING macro can be used to build up a String from streamable contents.
Object::View vKey = ... Object::View vValue = ... std::cout << vKey << " = " << vValue << std::endl; String::Handle hs = COH_TO_STRING(vKey << " = " << vValue);
| ||||
virtual bool | equals (Object::View vThat) const | |||
Return true iff the specified Object is "equal" to this Object. This method implements an equivalence relation on Objects:
The default implementation is a reference equality comparison.
| ||||
virtual size32_t | hashCode () const | |||
Return a hash code value for the Object. This method is supported for the benefit of hash-based containers.
The general contract of
The default implementation is identity based.
| ||||
Protected Member Functions | ||||
Method (String::View vsName) | ||||
Construct a Method of the specified name. | ||||
Protected Attributes | ||||
FinalView< String > | f_vsName | |||
The Method name. |
enum Modifier |
Modifier defines the various reflectable Method modifiers.
virtual int32_t getModifiers | ( | ) | const [pure virtual] |
virtual ObjectArray::View getParameterTypes | ( | ) | const [pure virtual] |
Return an array of Class::Views representing the method parameter types.
Implemented in TypedMethod.
virtual ClassView getReturnType | ( | ) | const [pure virtual] |
Return the Class::View representing the method's return type, or NULL for void.
Implemented in TypedMethod.
virtual ClassView getDeclaringClass | ( | ) | const [pure virtual] |
Return the Class::View representing the class in which the method is declared.
Implemented in TypedMethod.
virtual Object::Holder invoke | ( | Object::Holder | oh, | |
ObjectArray::View | vaArgs = NULL | |||
) | const [pure virtual] |
Execute the method.
oh | the object on which to invoke the method | |
vaArgs | the parameters, or NULL if the method takes none. |
Implemented in TypedMethod.
virtual Method::Handle annotate | ( | Annotation::View | vAnnontation | ) | [virtual] |
Add the specified Annotation to the element.
vAnnontation | the annotation |