Boost logo

Boost :

Subject: Re: [boost] Compile time reflection for IPC using
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2014-01-21 20:11:17


> > > Do you now about one approach (for two compilers (gcc 3.7, and MSVC
> > > (last)) emulate compile time reflection with difference scope?
> > >
> > > Like
> > >
> > > struct some {
> > > META_STRUCT(some);
> > >
> > > FLD(int, a);
> > > FLD(int, b);
> > >
> > > METH(int, call_0, (int, a));
> > > METH(int, call_1, (int, b));
> > > };
> > >
> > > void in()
> > > {
> > > typedef hl::reflection_extract<some>::field_accessors acc;
> > > some s;
> > > s.*hl::at<acc, a_accessor>::get() = 5; }
> > >
> > > We can see here https://github.com/ol72/hl/tree/ And you can try to
> > > compile this attached demo
> > > Use __J_ACTIVE define to see as reflection worked in json
> > > oriented
> > part
> > > of project. For which you should install json. Without this you can
> > > see ability take meta information by query.
> > >
> > > But global goal I think we understanding Our backend can be
> > > something else. Like client server , data base oriented structures
> > > in which we can use by SQL like C++ syntax
> > >
> > > We can make (and I made it )
> > > database like structures
> > >
> > > struct human_tables {
> > > TABLE(names)
> > > {
> > > fields((int) index, (std::string) name, .... );
> > > };
> > >
> > > TABLE(country) { fields((names_table::index) name, ... ); };
> > >
> > > TABLE(human)
> > > {
> > > indexes(names_table::index_field);
> > >
> > > fields((names_table::index_field) name,
> > > (country_table::index) country...);
> > > };
> > > };
> >
> > I think that CT reflection is a feature too low level to be exposed to
> > users if you want to implement IPC or RPC. And your proposed syntax
> > supports this claim as it is way too cumbersome for this purpose.
> > However, it certainly is desirable to have something like CT
> > reflection at your tool belt in order to implement IPC/RPC.
> >
> > I'd rather would like to see a functional interface which allows to
> > invoke a function remotely in the same way as you'd invoke it locally.
> > For instance:
> >
> > int func() { return 42; }
> >
> > REGISTER_FUNCTION(func); // defines func_type
> >
> > The type defined by the macro ('func_type') is a (very lightweight, no
> > members) callable type, which can be used to invoke the remote function:
> >
> > Synchronous invocation:
> >
> > func_type func_impl;
> > cout << func_impl(target); // 'target' is some means to identify
> the
> > remote process
> >
> > Asynchronous invocation:
> >
> > future<int> f = async(func_impl, target);
> > // do other things
> > cout << f.get(); // prints '42'
> >
> > Similar things can be done for member functions and variables (global
> > and member data).
> >
> > If you'd like to see this in action, this scheme is implemented by HPX
> > (https://github.com/STEllAR-GROUP/hpx/).
>
> I think this is not CT.

The code I showed is CT for sure.

This REGISTER_FUNCTION(func) expands to (amongst other things, mostly
related to serialization):

    typedef make_action<decltype(&func), &func>::type func_type;

where 'func_type' is something functionally equivalent to:

    struct func_type
    {
        // note the operator() exposes the same prototype as func()
        int operator()(<implementation-defined> target) const
        { /* do IPC/RPC as needed */ }
    };

Additionally you need special overloads for async(), but that's obvious.

HTH
Regards Hartmut
---------------
http://boost-spirit.com
http://stellar.cct.lsu.edu


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk