Member Class Reference

#include <reflectionbase.h>

Inheritance diagram for Member:

Detailed Description

Member is the root interface of the reflection hierarchy. A Member may be

All members except the global package have an enclosing container as their parent. For example, the method StringInterface::GetLength() has the class StringInterface as enclosing container, which has the maxon package as enclosing container, which has the global package as enclosing container.

Public Types

enum class  KIND {
  PACKAGE ,
  CLASS ,
  FUNCTION ,
  INSTANCE_FUNCTION ,
  CONST_INSTANCE_FUNCTION ,
  CONTAINER_TEST ,
  FUNCTION_TEST
}
 

Public Member Functions

enum maxon::reflection::Member::KIND MAXON_ENUM_FLAGS_CLASS (KIND)
 
MAXON_METHOD const ContainerGetEnclosingContainer () const
 
MAXON_METHOD KIND GetKind () const
 
MAXON_METHOD const IdGetSimpleName () const
 
MAXON_METHOD const IdGetId () const
 
MAXON_METHOD String ToString (const FormatStatement *fs=nullptr) const
 

Static Public Member Functions

static MAXON_METHOD Result< BoolGetMembers (const ValueReceiver< const Member & > &members)
 
static MAXON_METHOD const MemberFind (const Id &memberId)
 

Private Member Functions

 MAXON_INTERFACE_NONVIRTUAL (Member, MAXON_REFERENCE_NONE, "net.maxon.reflection.interface.member")
 

Member Enumeration Documentation

◆ KIND

enum KIND
strong

This enum defines the possible kinds of a Member. Exactly one of the flags is set in the value returned by GetKind().

Enumerator
PACKAGE 

The member is a Package.

CLASS 

The member is a Class.

FUNCTION 

The member is a Function (either at package scope, or a static class member).

INSTANCE_FUNCTION 

The member is a non-const instance function (i.e., non-static class member).

CONST_INSTANCE_FUNCTION 

The member is a const instance function (i.e., non-static class member).

CONTAINER_TEST 
FUNCTION_TEST 

Member Function Documentation

◆ MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( Member  ,
MAXON_REFERENCE_NONE  ,
"net.maxon.reflection.interface.member"   
)
private

◆ MAXON_ENUM_FLAGS_CLASS()

enum maxon::reflection::Member::KIND MAXON_ENUM_FLAGS_CLASS ( KIND  )

◆ GetEnclosingContainer()

MAXON_METHOD const Container* GetEnclosingContainer ( ) const

Returns the enclosing container of this member. All members except the global package have such an enclosing container: Functions and classes are nested in classes or packages, packages are nested in other packages.

Returns
The enclosing container of this member, or nullptr if this is the global package.

◆ GetKind()

MAXON_METHOD KIND GetKind ( ) const

Returns the kind of this member. This allows to tell whether this Member can be safely cast to a Package, Class or Function. The returned value has exactly one of the KIND flags set.

Returns
Kind of this member.

◆ GetSimpleName()

MAXON_METHOD const Id& GetSimpleName ( ) const

Returns the (unqualified) name of this member. E.g., for maxon::StringInterface::GetLength this is "GetLength".

Returns
Name of this member.

◆ GetId()

MAXON_METHOD const Id& GetId ( ) const

Returns a unique id for this member. This is the qualified name of the member (with dot as separator), plus optionally an additional code for disambiguation, separated by "@". For functions, a hashcode which depends on the parameter and return types is used to disambiguate between overloads (such as "net.maxon.asin@919429e0").

The function Find() allows to find a Member for the id.

Returns
Unique id for this member.

◆ ToString()

MAXON_METHOD String ToString ( const FormatStatement fs = nullptr) const

Returns a readable string of the content.

Parameters
[in]fsNullptr or additional formatting instruction. Currently no additional formatting instructions are supported.
Returns
The converted result.

◆ GetMembers()

static MAXON_METHOD Result<Bool> GetMembers ( const ValueReceiver< const Member & > &  members)
static

Yields all registered members.

◆ Find()

static MAXON_METHOD const Member* Find ( const Id memberId)
static

Finds the member whose id is memberId. The id has to be in a format as specified by GetId(). If there is no member with the given memberId, nullptr is returned.

Parameters
[in]memberIdA member id.
Returns
The member with the given memberId, or nullptr.