Proton
1.1.1
Make porting easy from Python to C++11
|
Core reference template supporting interface through inheritance/multiple inheritance. More...
Classes | |
struct | proton::ref_< objT, allocator > |
The core reference support template. More... | |
struct | proton::key_hash< T > |
general key_hash for refs. More... | |
struct | proton::subkey_hash< T, key_seq > |
general subkey_hash for refs. More... |
Macros | |
#define | PROTON_COPY_DECL(type) |
declare copy_to(). | |
#define | PROTON_COPY_DECL_NV(type) |
declare copy_to() without virtual. | |
#define | PROTON_KEY_DECL(type) |
general operator< & operator== for objects. |
Functions | |
template<typename refT > | |
bool | proton::is_null (const refT &x) |
test a ref null or not. | |
template<typename refT > | |
bool | proton::is_valid (const refT &x) |
test a ref valid or not. | |
template<typename refT > | |
refT | proton::copy (const refT &x) |
Generate a copy of object. | |
template<typename refT > | |
void | proton::reset (refT &x) |
reset a ref to release its object if any. | |
template<typename refT > | |
long | proton::ref_count (const refT &x) |
get the reference count of the object. | |
template<typename T , typename refT > | |
T | proton::cast (const refT &x) |
cast from a ref type to another. | |
template<typename T > | |
std::ostream & | proton::operator<< (typename T::proton_ostream_t &s, const T &y) |
general output for refs. |
Variables | |
init_alloc | proton::alloc |
explicitly demand to initialize an object. |
Core reference template supporting interface through inheritance/multiple inheritance.
#define PROTON_COPY_DECL | ( | type | ) |
#define PROTON_COPY_DECL_NV | ( | type | ) |
#define PROTON_KEY_DECL | ( | type | ) |
T proton::cast | ( | const refT & | x | ) |
cast from a ref type to another.
if casting fails, throw std::bad_cast().
x | the original ref |
Definition at line 160 of file ref.hpp.
References proton::is_null().
refT proton::copy | ( | const refT & | x | ) |
Generate a copy of object.
Note: the alloc_t of refT must support duplicate() like smart_allocator.
x | a ref to an obj supporting the method: void copy_to(void* new_addr)const. You can use PROTON_COPY_DECL() or PROTON_COPY_DECL_NV() to declare copy_to() in the obj class. |
Definition at line 123 of file ref.hpp.
References proton::is_null().
bool proton::is_null | ( | const refT & | x | ) |
test a ref null or not.
x | the ref to be checked |
Definition at line 84 of file ref.hpp.
Referenced by proton::cast(), proton::copy(), proton::ref_< objT, allocator >::operator()(), proton::ref_< objT, allocator >::operator<(), proton::operator<<(), proton::ref_< objT, allocator >::operator==(), and proton::ref_< objT, allocator >::operator[]().
bool proton::is_valid | ( | const refT & | x | ) |
std::ostream& proton::operator<< | ( | typename T::proton_ostream_t & | s, |
const T & | y | ||
) |
general output for refs.
Need T::obj_t to implenment the method: void output(std::ostream& s)const. Don't forget virtual when needed.
Definition at line 555 of file ref.hpp.
References proton::is_null().
long proton::ref_count | ( | const refT & | x | ) |