29 struct Payload:
public T
32 Payload(): count(1) {}
33 Payload(
const T& x): T(x), count(1) {}
36 void refdec() {
if (item){item->count--;
if (item->count==0)
delete item;}}
37 void asg(
const ref& x)
40 {item=x.item; item->count++;}
44 void newitem() {item=
new Payload;}
45 void newitem(
const T& x) {item=
new Payload(x);}
46 template <
class U>
bool operator==(
const U&)
const;
49 ref(
const ref& x) {asg(x);}
50 ref(
const T& x) {newitem(x);}
51 ref& operator=(
const ref& x) {
if (x.item!=item) {refdec(); asg(x);}
return *
this;}
52 ref& operator=(
const T& x) {refdec(); newitem(x);
return *
this;}
65 T&
operator*() {
if (!item) newitem();
return *(T*)item;}
67 const T*
operator->()
const {assert(item);
return (T*)item;}
69 const T&
operator*()
const {assert(item);
return *(T*)item;}
73 bool nullref()
const {
return item==NULL;}
75 operator bool ()
const {
return !
nullref();}
77 int refCount()
const {
if (item) {
return item->count;}
else return 0;}
78 bool operator==(
const ref& x)
const {
return x.item==item;}
79 bool operator==(
const T* x)
const {
return x==item;}
80 bool operator==(
const T& x)
const {
return x==*item;}
82 bool operator!=(
const U& x)
const {
return !operator==(x);}
84 bool operator<(
const ref& x)
const {
return item<x.item;}
85 void swap(
ref& x) {Payload*tmp=x.item; x.item=item; item=tmp;}
103 #pragma omit pack classdesc::ref 104 #pragma omit unpack classdesc::ref 105 #pragma omit isa classdesc::ref Metaprogramming support for processing functions of multiple arguments.
const T * operator->() const
dereference - throws in debug mode if null
Definition: ref.h:67
const T & operator*() const
dereference - throws in debug mode if null
Definition: ref.h:69
T * operator->()
dereference - creates default object if null
Definition: ref.h:55
Definition: function.h:70
class to allow access to private members
Definition: classdesc_access.h:21
bool nullref() const
true if reference is null
Definition: ref.h:73
T & operator*()
dereference - creates default object if null
Definition: ref.h:65
void nullify()
make reference null
Definition: ref.h:71
class to allow access to private members
Definition: classdesc_access.h:22
int refCount() const
return the payloads reference count
Definition: ref.h:77
Contains definitions related to classdesc functionality.
Definition: arrays.h:2514
Definition: pack_base.h:124
serialisation for dynamic structures (graphs/trees and so on)
Contains access_* structs, and nothing else. These structs are used to gain access to private members...
Definition: accessor.h:55
Definition: pack_graph.h:73