Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::api< Interface, Transform > Class Template Reference

#include <api.hpp>

Inheritance diagram for fc::api< Interface, Transform >:
Collaboration diagram for fc::api< Interface, Transform >:

Public Types

typedef vtable< Interface, Transform > vtable_type
 

Public Member Functions

 api ()
 
template<typename T >
 api (const T &p)
 
 api (const api &cpy)
 
virtual ~api ()
 
virtual uint64_t get_handle () const override
 
virtual api_id_type register_api (api_connection &conn) const override
 
vtable_typeoperator* () const
 
vtable_typeoperator-> () const
 
- Public Member Functions inherited from fc::api_base
 api_base ()
 
virtual ~api_base ()
 
template<typename T >
api< T, identity_memberas ()
 
template<typename T >
api< Tas ()
 

Protected Attributes

std::shared_ptr< vtable_type_vtable
 
std::shared_ptr< fc::any_data
 

Friends

bool operator== (const api &a, const api &b)
 
bool operator!= (const api &a, const api &b)
 

Detailed Description

template<typename Interface, typename Transform = identity_member>
class fc::api< Interface, Transform >

Definition at line 67 of file api.hpp.

Member Typedef Documentation

◆ vtable_type

template<typename Interface , typename Transform = identity_member>
vtable<Interface,Transform> fc::api< Interface, Transform >::vtable_type

Definition at line 69 of file api.hpp.

Constructor & Destructor Documentation

◆ api() [1/3]

template<typename Interface , typename Transform = identity_member>
fc::api< Interface, Transform >::api ( )
inline

Definition at line 71 of file api.hpp.

71:_vtable( std::make_shared<vtable_type>() ) {}
std::shared_ptr< vtable_type > _vtable
Definition api.hpp:97

◆ api() [2/3]

template<typename Interface , typename Transform = identity_member>
template<typename T >
fc::api< Interface, Transform >::api ( const T & p)
inline

T is anything with pointer semantics

Definition at line 75 of file api.hpp.

76 :_vtable( std::make_shared<vtable_type>() )
77 {
78 _data = std::make_shared<fc::any>(p);
79 T& ptr = boost::any_cast<T&>(*_data);
80 auto& pointed_at = *ptr;
81 typedef typename std::remove_reference<decltype(pointed_at)>::type source_vtable_type;
82 _vtable->FC_CALL_MEMBER_TEMPLATE_KEYWORD visit_other( vtable_copy_visitor<source_vtable_type>(pointed_at) );
83 }
const mie::Vuint & p
Definition bn.cpp:27
std::shared_ptr< fc::any > _data
Definition api.hpp:98
#define T(meth, val, expected)

◆ api() [3/3]

template<typename Interface , typename Transform = identity_member>
fc::api< Interface, Transform >::api ( const api< Interface, Transform > & cpy)
inline

Definition at line 85 of file api.hpp.

85:_vtable(cpy._vtable),_data(cpy._data) {}

◆ ~api()

template<typename Interface , typename Transform = identity_member>
virtual fc::api< Interface, Transform >::~api ( )
inlinevirtual

Definition at line 86 of file api.hpp.

86{}

Member Function Documentation

◆ get_handle()

template<typename Interface , typename Transform = identity_member>
virtual uint64_t fc::api< Interface, Transform >::get_handle ( ) const
inlineoverridevirtual

Implements fc::api_base.

Definition at line 90 of file api.hpp.

90{ return uint64_t(_data.get()); }
unsigned __int64 uint64_t
Definition stdint.h:136

◆ operator*()

template<typename Interface , typename Transform = identity_member>
vtable_type & fc::api< Interface, Transform >::operator* ( ) const
inline

Definition at line 93 of file api.hpp.

93{ FC_ASSERT( _vtable ); return *_vtable; }
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.

◆ operator->()

template<typename Interface , typename Transform = identity_member>
vtable_type * fc::api< Interface, Transform >::operator-> ( ) const
inline

Definition at line 94 of file api.hpp.

94{ FC_ASSERT( _vtable ); return _vtable.get(); }

◆ register_api()

template<typename Interface , typename Transform >
api_id_type fc::api< Interface, Transform >::register_api ( api_connection & conn) const
overridevirtual

It is slightly unclean tight coupling to have this method in the api class. It breaks encapsulation by requiring an api class method to have a pointer to an api_connection. The reason this is necessary is we have a goal of being able to call register_api() on an api<T> through its base class api_base. But register_api() must know the template parameters!

The only reasonable way to achieve the goal is to implement register_api() as a method in api<T> (which obviously knows the template parameter T), then make the implementation accessible through the base class (by making it a pure virtual method in the base class which is overridden by the subclass's implementation).

It is slightly unclean tight coupling to have this method in the api class. It breaks encapsulation by requiring an api class method to have a pointer to an binary_api_connection. The reason this is necessary is we have a goal of being able to call register_api() on an api<T> through its base class api_base. But register_api() must know the template parameters!

The only reasonable way to achieve the goal is to implement register_api() as a method in api<T> (which obviously knows the template parameter T), then make the implementation accessible through the base class (by making it a pure virtual method in the base class which is overridden by the subclass's implementation).

Implements fc::api_base.

Definition at line 459 of file api_connection.hpp.

460 {
461 return conn.register_api( *this );
462 }
Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ operator!=

template<typename Interface , typename Transform = identity_member>
bool operator!= ( const api< Interface, Transform > & a,
const api< Interface, Transform > & b )
friend

Definition at line 89 of file api.hpp.

89{ return !(a._data == b._data && a._vtable == b._vtable); }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181

◆ operator==

template<typename Interface , typename Transform = identity_member>
bool operator== ( const api< Interface, Transform > & a,
const api< Interface, Transform > & b )
friend

Definition at line 88 of file api.hpp.

88{ return a._data == b._data && a._vtable == b._vtable; }

Member Data Documentation

◆ _data

template<typename Interface , typename Transform = identity_member>
std::shared_ptr<fc::any> fc::api< Interface, Transform >::_data
protected

Definition at line 98 of file api.hpp.

◆ _vtable

template<typename Interface , typename Transform = identity_member>
std::shared_ptr<vtable_type> fc::api< Interface, Transform >::_vtable
protected

Definition at line 97 of file api.hpp.


The documentation for this class was generated from the following files: