libcppa  Version 0.1
Public Member Functions | Static Public Member Functions | Related Functions
cppa::object Class Reference

#include <object.hpp>

Inherited by cppa::detail::obj_impl< T >.

List of all members.

Public Member Functions

 object (void *val, const uniform_type_info *utinfo)
 object ()
 object (object &&other)
 object (const object &other)
objectoperator= (object &&other)
objectoperator= (const object &other)
const uniform_type_infotype () const
const void * value () const
void * mutable_value ()

Static Public Member Functions

template<typename T >
static object from (T &&what)

Related Functions

(Note that these are not member functions.)

template<typename T >
T & get_ref (object &obj)
template<typename T >
const T & get (const object &obj)

Detailed Description

An abstraction class that stores an instance of an announced type.


Constructor & Destructor Documentation

cppa::object::object ( void *  val,
const uniform_type_info utinfo 
)

Creates an object of type utinfo with value val.

Warning:
object takes ownership of val.
Precondition:
 val != nullptr && utinfo != nullptr 
cppa::object::object ( )

Creates an empty object.

Postcondition:
{type() == *uniform_typeid<util::void_type>()}
cppa::object::object ( object &&  other)

Creates an object and moves type and value from other to this.

cppa::object::object ( const object other)

Creates a (deep) copy of other.

Postcondition:
{*this == other}

Member Function Documentation

template<typename T >
object cppa::object::from ( T &&  what) [static]

Creates an object from what.

Parameters:
whatValue of an announced type.
Returns:
An object whose value was initialized with what.
Postcondition:
 type() == *uniform_typeid<T>() 
Exceptions:
std::runtime_errorif T is not announced.
void* cppa::object::mutable_value ( )

Gets the stored value.

Returns:
A mutable pointer to the currently stored value.
See also:
get_ref(object&)
object& cppa::object::operator= ( object &&  other)

Moves the content from other to this.

Returns:
*this
object& cppa::object::operator= ( const object other)

Creates a (deep) copy of other and assigns it to this.

Returns:
*this
const uniform_type_info& cppa::object::type ( ) const

Gets the RTTI of this object.

Returns:
A uniform_type_info describing the current type of this.
const void* cppa::object::value ( ) const

Gets the stored value.

Returns:
A const pointer to the currently stored value.
See also:
get(const object&)

Friends And Related Function Documentation

template<typename T >
const T & get ( const object obj) [related]

Grants const access to the stored value of obj.

Parameters:
objObject with obj.type() == typeid(T).
Returns:
A const reference to the value stored in obj.
Exceptions:
std::invalid_argumentif obj.type() != typeid(T)
template<typename T >
T & get_ref ( object obj) [related]

Grants mutable access to the stored value of obj.

Parameters:
objObject with obj.type() == typeid(T).
Returns:
A mutable reference to the value stored in obj.
Exceptions:
std::invalid_argumentif obj.type() != typeid(T)

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