9 #define DO_NOT_USE_SELF
10 #ifdef DO_NOT_USE_SELF
22 Self(Data
const& d ): data_(d) { }
36 bool same(
Self const& s)
const {
return false; }
37 bool equal(
Self const& s)
const {
return data_ == s.data_; }
157 Kernel(Body
const* master):
158 data_(new Data( )), counter_(1), master_(master) {
161 Kernel(Body
const* master, Data
const& d):
162 data_(new Data(d)), counter_(1), master_(master) {
174 --(pointer_->counter_);
175 if (pointer_->counter_ <= 0) {
178 else if (pointer_->master_ ==
this) {
179 pointer_->master_ = NULL;
183 Body( ): pointer_(new Kernel(this )), counter_(1) { }
184 Body(Data
const& d): pointer_(new Kernel(this, d)), counter_(1) { }
185 Body(Body
const& b): pointer_(b.pointer_ ), counter_(1) {
186 ++(pointer_->counter_);
195 pointer_ = b.pointer_;
196 ++(pointer_->counter_);
200 Data
const* access()
const {
201 return pointer_->data_;
205 if (pointer_->counter_ > 1) {
206 --(pointer_->counter_);
207 Kernel* dupl =
new Kernel(
this, *pointer_->data_);
208 if (pointer_->master_ ==
this) {
209 std::swap(pointer_->data_, dupl->data_);
210 pointer_->master_ = NULL;
214 else if (pointer_->master_ == NULL) {
215 pointer_->master_ =
this;
217 return pointer_->data_;
232 if (body_->detach() <= 0) {
240 Self(): body_(new Body()) {
248 Self(Data
const& d): body_(new Body(d)) {
260 body_ =
new Body(*b.body_);
279 return body_->access();
286 return body_->modify();
291 return *((
Self*)
this);
301 if (body_->access() != s.body_->access()) {
314 if (body_ != s.body_) {
345 return (body_ == s.body_);
357 if (
same(s) || body_->access() == s.body_->access())
return true;
358 return (*body_->access() == *s.body_->access());
367 return (body_ < s.body_);
Data const * operator->() const
Self const & copyFrom(Self const &s)
bool referenceLess(Self const &s) const
Self(Self const &b, DuplicateType d)
void operator=(Self const &a)
bool same(Self const &s) const
bool equal(Self const &s) const
Self & operator()() const
Self const & referenceFrom(Self const &s)
Self const & duplicateFrom(Self const &s, DuplicateType t)