00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _SK_UTIL_SLOT_POLICY_ALIASING_HXX_
00009 #define _SK_UTIL_SLOT_POLICY_ALIASING_HXX_
00010
00011 #include <sk/util/slot/policy/Storing.hxx>
00012 #include <sk/util/slot/mixin/LinkCounter.h>
00013
00014 namespace sk {
00015 namespace util {
00016 namespace slot {
00017 namespace policy {
00018 template<typename T>
00019 class Aliasing
00020 : public Storing<T>
00021 {
00022 public:
00023 Aliasing() {}
00024
00025 Aliasing(const Aliasing<T>& other) {
00026 alias(other);
00027 }
00028
00029 Aliasing(const Storing<T>& other) {
00030 alias(other);
00031 }
00032
00033 void operator=(const Aliasing<T>& other) {
00034 alias(other);
00035 }
00036
00037 void operator=(const Storing<T>& other) {
00038 alias(other);
00039 }
00040
00041 private:
00042 void alias(const Storing<T>& other) {
00043 if(&other == this) {
00044 return;
00045 }
00046 Storing<T>::clearSlot();
00047
00048 if(hasSlot(other) == true) {
00049 setObject(getSlot(other).get());
00050 }
00051 }
00052 };
00053 }
00054 }
00055 }
00056 }
00057
00058 #endif