diff --git a/include/fc/api.hpp b/include/fc/api.hpp index 943aedd..5ef581b 100644 --- a/include/fc/api.hpp +++ b/include/fc/api.hpp @@ -3,33 +3,19 @@ #include #include #include -#include -#include -#include -#include -#include namespace fc { struct identity_member { template - static std::function functor( P&& p, R (C::*mem_func)(Args...) ) { - return std::function([=](Args... args){ return (p->*mem_func)(args...); }); - } + static std::function functor( P&& p, R (C::*mem_func)(Args...) ); template - static std::function functor( P&& p, R (C::*mem_func)(Args...)const ) { - return std::function([=](Args... args){ return (p->*mem_func)(args...); }); - } + static std::function functor( P&& p, R (C::*mem_func)(Args...)const ); }; - template< typename Interface, typename Transform > struct vtable : public std::enable_shared_from_this> - { - private: - vtable(); - }; + { private: vtable(); }; - template struct vtable_copy_visitor { typedef OtherType other_type; @@ -39,10 +25,7 @@ namespace fc { template void operator()( const char* name, std::function& memb, MemberPtr m )const { OtherType* src = &_source; - memb = [src,m]( Args... args ){ - wdump( (uint64_t(src) ) ); - return (src->*m)(args...); - }; + memb = [src,m]( Args... args ){ return (src->*m)(args...); }; } OtherType& _source; }; @@ -52,9 +35,7 @@ namespace fc { public: typedef vtable vtable_type; - api() - :_vtable( std::make_shared() ) - {} + api():_vtable( std::make_shared() ) {} /** T is anything with pointer semantics */ template @@ -68,30 +49,26 @@ namespace fc { _vtable->template visit_other( vtable_copy_visitor(pointed_at) ); } - api( const api& cpy ) - :_vtable(cpy._vtable),_data(cpy._data) - { - } + api( const api& cpy ):_vtable(cpy._vtable),_data(cpy._data) {} friend bool operator == ( const api& a, const api& b ) { return a._data == b._data && a._vtable == b._vtable; } friend bool operator != ( const api& a, const api& b ) { return !(a._data == b._data && a._vtable == b._vtable); } - vtable_type& operator*()const { wdump((uint64_t(this))); assert(_vtable); FC_ASSERT( _vtable ); return *_vtable; } - vtable_type* operator->()const { - assert(_vtable); - FC_ASSERT( _vtable ); - return _vtable.get(); - } - void test(); + vtable_type& operator*()const { FC_ASSERT( _vtable ); return *_vtable; } + vtable_type* operator->()const { FC_ASSERT( _vtable ); return _vtable.get(); } protected: std::shared_ptr _vtable; std::shared_ptr _data; }; +} // namespace fc -} - +#include +#include +#include +#include +#include #include #include @@ -117,6 +94,5 @@ namespace fc { \ BOOST_PP_SEQ_FOR_EACH( FC_API_VTABLE_DEFINE_VISIT, CLASS, METHODS ) \ } \ }; \ - } -//#undef FC_API_VTABLE_DEFINE_MEMBER -//#undef FC_API_VTABLE_DEFINE_VISIT +} + diff --git a/include/fc/rpc/api_connection.hpp b/include/fc/rpc/api_connection.hpp index 9e9eb22..02b7bea 100644 --- a/include/fc/rpc/api_connection.hpp +++ b/include/fc/rpc/api_connection.hpp @@ -54,15 +54,6 @@ namespace fc { return f(); } - /* - template - R call_generic( const std::function& f, variants::const_iterator a0, variants::const_iterator e )const - { - FC_ASSERT( a0 != e ); - return f(a0->as()); - } - */ - template R call_generic( const std::function& f, variants::const_iterator a0, variants::const_iterator e )const {