objectize_macros.hh File Reference

#include <lestes/std/objectize.hh>

Include dependency graph for objectize_macros.hh:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define specialize_objectize_for_enum(type)
#define specialize_objectize_nodump(type)
#define specialize_objectize_nodump_reference(type)


Define Documentation

#define specialize_objectize_for_enum ( type   ) 

Value:

template<>                                                                      \
class objectize< type > : public objectize<lint> {                              \
public:                                                                         \
        static ptr< objectize<lint> > create( type a_value )                    \
        {                                                                       \
                return objectize<lint>::create( static_cast<lint>(a_value) );   \
        }                                                                       \
private:                                                                        \
        /*! Hide the constructor */                                             \
        objectize< type >();                                                    \
}
Specializes objectize<T> for given enum type. The dumper visitor is called as if the value was a lint; the actual value is static_cast to lint.

The macro must be used inside lestes::std and must not be used more than once for the same type, o for a type that was passed to the other macro, specialize_objectize_nodump().

Usually, you would pass fully qualified name as the type argument.

Actually, the only thing that is implemented here is the create method. It static casts the argument and returns a pointer to objectize<lint>.

#define specialize_objectize_nodump ( type   ) 

Value:

template<>                                                                      \
class objectize< type > : public object {                                       \
public:                                                                         \
        static ptr< objectize< type > > create( const type & )                  \
        {                                                                       \
                /* the agument is not used at all */                            \
                return new objectize< type >();                                 \
        }                                                                       \
        virtual void accept_dumper_visitor( ptr<dumper_visitor> v )             \
        {                                                                       \
                return v->visit_nodump();                                       \
        }                                                                       \
protected:                                                                      \
        objectize< type >()                                                     \
        {}                                                                      \
}
Specializes objectize<T> for given type. The dumper visitor's visit_nodump() is called in accept_dumper_visitor().

The macro must be used inside lestes::std and must not be used more than once for the same type, or for a type that was passed to the other macro, specialize_objectize_for_enum().

Usually, you would pass fully qualified name as the type argument.

Note that The create method does not use its argument in any way. This, and the fact that const reference is used, ensures that no further requirements are placed on the given type. If reference was not used, the type would have to publicly support copy-construction. This has a disadvantage, though: The type argument cannot be a reference type. Other macro is provided for those.

#define specialize_objectize_nodump_reference ( type   ) 

Value:

template<>                                                                      \
class objectize< type > : public object {                                       \
public:                                                                         \
        static ptr< objectize< type > > create( const type )                    \
        {                                                                       \
                /* the agument is not used at all */                            \
                return new objectize< type >();                                 \
        }                                                                       \
        virtual void accept_dumper_visitor( ptr<dumper_visitor> v )             \
        {                                                                       \
                return v->visit_nodump();                                       \
        }                                                                       \
protected:                                                                      \
        objectize< type >()                                                     \
        {}                                                                      \
}
Specializes objectize<T> for given _reference_ type. The only difference when compared to specialize_objectize_nodump is that the create method takes argument of the type itself, which makes the generated specialization compilable for a reference type.

See documentation for specialize_objectize_nodump macro.


Generated on Mon Feb 12 18:39:40 2007 for lestes by doxygen 1.5.1-20070107