Mirror reflection library 0.5.13
Classes | Typedefs

Mirror - Raw pointers

Classes

class  mirror::raw_ptr_templ< Auditor, BadCastPolicy, BasePtrType >
 Raw pointer template using a custom type comparator and a bad cast policy. More...

Typedefs

typedef raw_ptr_templ
< aux::ptr_cast_auditor
< default_type_cmp >
, default_bad_cast_policy,
void * > 
mirror::raw_ptr
 The basic raw pointer type.
typedef raw_ptr_templ
< aux::ptr_cast_auditor
< default_type_cmp >
, default_bad_cast_policy,
std::shared_ptr< void >> 
mirror::shared_raw_ptr
 Raw pointer type with shared-ownership.
typedef raw_ptr_templ
< aux::ptr_cast_auditor
< default_type_cmp >
, default_bad_cast_policy,
std::unique_ptr< void >> 
mirror::unique_raw_ptr
 Raw pointer type with unique-ownership.

Detailed Description

Simple typechecking replacement for void* and partial replacement for static_cast<T>().

The purpose of 'raw' pointers is to provide safer, run-time typechecked replacement for the void*, where the use of an untyped pointer cannot be avoided or seems as the best option. More precisely the raw_ptr is usable in situations, where pointers to instances are temporarily cast to untyped pointers and then cast back.

As mentioned elsewhere, several reflection facilities use for the purpose of the base-level-to-meta-level transition a class that is an universal (and usually also the default) ancestor for all other types or classes. This is not a very good idea in general and especially not, if the native types should be reflected too. Thus, in order to refer to instances of any type the untyped void* can be used. However by using void* we loose all the information about the type pointed-to. This is where by using raw_ptr we can gain some of the type-safety back, if only at the run-time.

The raw pointers are not applicable to situations, where the pointer is used in operations like bit-block transfer or examination. i.e. where it is not cast back to the original type, and the block of memory pointed-to is handled as a sequence of bytes or bits regardless of the real data type.


Typedef Documentation

typedef raw_ptr_templ< aux::ptr_cast_auditor<default_type_cmp>, default_bad_cast_policy, void*> mirror::raw_ptr

The basic raw pointer type.

This is an instantiation of the raw_ptr_templ template using the default type comparator, the default on-bad-cast policy and the void* as the underlying pointer type.

This type should be used when the ownership of the data pointed-to is managed by the application logic i.e. not by the pointer itself.

typedef raw_ptr_templ< aux::ptr_cast_auditor<default_type_cmp>, default_bad_cast_policy, std::shared_ptr<void>> mirror::shared_raw_ptr

Raw pointer type with shared-ownership.

This is an instantiation of the raw_ptr_templ template using the default type comparator, the default on-bad-cast policy and the shared_ptr<void> smart pointer as the underlying pointer type.

The ownership and the deallocation of the data pointed-to is managed by this pointer.

typedef raw_ptr_templ< aux::ptr_cast_auditor<default_type_cmp>, default_bad_cast_policy, std::unique_ptr<void>> mirror::unique_raw_ptr

Raw pointer type with unique-ownership.

This is an instantiation of the raw_ptr_templ template using the default type comparator, the default on-bad-cast policy and the unique_ptr<void> smart pointer as the underlying pointer type.

The ownership and the deallocation of the data pointed-to is managed by this pointer.


Copyright © 2006-2011 Matus Chochlik, University of Zilina, Zilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Fri Dec 16 2011 by Doxygen (version 1.7.3).
Important note: Although the 'boostified' version of Mirror uses the Boost C++ libraries Coding Guidelines and is implemented inside of the boost namespace, it IS NOT an officially reviewed and accepted Boost library. Mirror is being developed with the intention to be submitted for review for inclusion to the Boost C++ libraries.