Oracle Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.1.2)

E26041-01

TypedMethod Class Template Reference

#include <coherence/lang/TypedMethod.hpp>

Inherits Method.

List of all members.


Detailed Description

template<class P, class R, class C, class H, P M, class A1 = void, class A2 = void, class A3 = void, class A4 = void, class A5 = void, class A6 = void, class A7 = void, class A8 = void>
class coherence::lang::TypedMethod< P, R, C, H, M, A1, A2, A3, A4, A5, A6, A7, A8 >

TypedMethod provides a template based implementation for building Methods which delegate to member function pointers.

Rather then making direct use of this class it is recommended to utilize the following helper macros. For each of these methods there are nine variants suffixed 0..8 which indicate the number of arguments the method takes.

Additionally the following macros will create setter and getter Methods for a "property".

These macros output Method objects which can then be registered with their corresponding Class object. This registration can either be performed as part of the Class registration, or it can be done in multiple COH_REGISTER_METHOD blocks, allowing the Method definition to reside next to the actual method implementation.

 // Person.hpp
 class Person
      : public class_spec<Person>
      {
      friend class factory<Person>;

      protected:
          Person(String::View vsName = String::null_string, int32_t nAge = 0);

      public:
          virtual void setName(String::View vsName);
          virtual String::View getName() const;

          virtual void setAge(int32_t nAge);
          virtual int32_t getAge() const;
      ...
      };

 // Person.cpp - using single class registration block

 COH_REGISTER_CLASS(TypedClass<Person>::create()
      ->declare(COH_CONSTRUCTOR2(Person, String::View, BoxHandle<const Integer32>))
      ->declare(COH_PROPERTY(Person, Name, String::View))
      ->declare(COH_BOX_PROPERTY(Person, Age, Integer32::View));

 // Person.cpp - using multi method registration blocks

 COH_REGISTER_TYPED_CLASS(Person);

 Person::Person(String::View vsName, int32_t nAge)
    {
    ...
    }
 COH_REGISTER_METHOD(Person, COH_CONSTRUCTOR2(Person, String::View, BoxHandle<const Integer32>));

 void Person::setName(String::View vsName)
     {
     ...
     }
 COH_REGISTER_METHOD(Person, COH_METHOD1(void, Person::Handle, setName, String::View));

 String::View Person::getName() const
     {
     ...
     }
 COH_REGISTER_METHOD(Person, COH_METHOD0(String::View, Person::View, getName));

 void Person::setAge(int32_t nAge)
     {
     ...
     }
 COH_REGISTER_METHOD(Person, COH_METHOD1(void, Person::Handle, setName, BoxHandle<const Integer32>));

 int32_t Person::getAge() const
     {
     ...
     }
 COH_REGISTER_METHOD(Person, COH_METHOD0(BoxHandle<const Integer32>, Person::View, getName));

Author:
mf 2011.02.28
Since:
Coherence 3.7.1

Public Types

typedef spec::Handle Handle
 TypedMethod<P, R, C, H, M, A1, A2, A3, A4, A5, A6, A7, A8> Handle definition.
typedef spec::View View
 TypedMethod<P, R, C, H, M, A1, A2, A3, A4, A5, A6, A7, A8> View definition.
typedef spec::Holder Holder
 TypedMethod<P, R, C, H, M, A1, A2, A3, A4, A5, A6, A7, A8> Holder definition.

Public Member Functions

virtual int32_t getModifiers () const
 Return the method modifiers.

Returns:
the method modifiers

virtual ObjectArray::View getParameterTypes () const
 Return an array of Class::Views representing the method parameter types.

Returns:
the parameter types

virtual Method::ClassView getReturnType () const
 Return the Class::View representing the method's return type, or NULL for void.

Returns:
the return type

virtual Method::ClassView getDeclaringClass () const
 Return the Class::View representing the class in which the method is declared.

Returns:
the declaring class

virtual Object::Holder invoke (Object::Holder oh, ObjectArray::View vaArgs) const
 Execute the method.

Parameters:
oh the object on which to invoke the method
vaArgs the parameters, or NULL if the method takes none.
Returns:
the method return value, or NULL if the method has a void return


Protected Member Functions

 TypedMethod (String::View vsName)
 Construct a TypedMethod.

Constructor & Destructor Documentation

TypedMethod ( String::View  vsName  )  [inline, protected]

Construct a TypedMethod.

Parameters:
vsName the method name


The documentation for this class was generated from the following file:
Copyright © 2000, 2013, Oracle and/or its affiliates. All rights reserved.