|
template<typename Class , typename Ret , typename... Args> |
| Method (const Name &name, Ret(Class::*method)(Args...)) |
| Creates a new method definition using the given name and the given pointer to member function.
|
|
| Method (const Method &other)=default |
| Default copy constructor.
|
|
| Method (Method &&other) noexcept=default |
| Default move constructor.
|
|
Method & | operator= (const Method &other)=default |
| Default copy assignment operator.
|
|
Method & | operator= (Method &&other) noexcept=default |
| Default move assignment operator.
|
|
template<typename Ret > |
size_t | getReturnSize () const |
| Register the size of the return type.
|
|
template<typename... Args> |
void | setSizes () |
| Register argument sizes.
|
|
template<typename... Args> |
void | compareSizes () const |
| Compare the sizes of a set of given arguments to the stored argument sizes.
|
|
template<typename Class , typename... Arg> |
void | call (Class *object, Arg... arg) const |
| Call the method named name on the given object, with the given arguments.
|
|
template<typename Class , typename Ret , typename... Arg> |
Ret | callWithReturn (Class *object, Ret, Arg... arg) const |
| Call the method named name on the given object, with the given arguments, returning a value of type Ret.
|
|
const Name & | getName () const |
| Get the name of this method.
|
|
template<> |
size_t | getReturnSize () const |
| Specialized for void return type.
|
|
template<> |
void | setSizes () |
| Specialized for zero arguments.
|
|
template<> |
void | compareSizes () const |
| Specialized for zero arguments.
|
|
Simple method definition.
Stores a pointer to member function object with some metadata about the arguments of the member function.
Example:
struct MyStruct
{
void foo(int i) { printf("Number: %d", i); }
};
void test()
{
Method methods[] = {
Method(Name("foo"), &MyStruct::foo),
};
auto & type = TypeDatabase::createType<MyStruct>().setMethods(methods);
auto instance = TypeDatabase::createInstance<MyStruct>("MyStruct");
type.getMethod("foo")->call(instance, 42);
}
...
Outputs the following:
Number: 42
Provides a weakly referenced view over the contents of a string.
Possible future improvements include:
- Use internal or external type system to validate all arguments properly.
Definition at line 71 of file Method.h.
template<typename Class , typename... Arg>
void Cogs::Reflection::Method::call |
( |
Class * |
object, |
|
|
Arg... |
arg |
|
) |
| const |
|
inline |
Call the method named name on the given object, with the given arguments.
In debug builds, the arguments passed to this method will have basic validation performed at runtime. In release builds, no checking is performed.
Definition at line 144 of file Method.h.
Referenced by Cogs::Core::EchoSounder::OctProviderSystem::update().
template<typename Class , typename Ret , typename... Arg>
Ret Cogs::Reflection::Method::callWithReturn |
( |
Class * |
object, |
|
|
Ret |
, |
|
|
Arg... |
arg |
|
) |
| const |
|
inline |
Call the method named name on the given object, with the given arguments, returning a value of type Ret.
In debug builds, the arguments passed to this method will have basic validation performed at runtime. In release builds, no checking is performed.
- Returns
- A value of type Ret.
Definition at line 168 of file Method.h.