#include "DSProperty.h"
namespace display_server {
- DSObjectPrivate::DSObjectPrivate(DSObject *p_ptr, std::string name) :
+ DSObjectPrivate::DSObjectPrivate(DSObject *p_ptr) :
__p_ptr(p_ptr)
{
- __type_info.name = name;
}
DSObjectPrivate::~DSObjectPrivate()
{
+ __type_info.name.clear();
+ __observers.clear();
+ __properties.clear();
}
void DSObjectPrivate::attachDestroyObserver(DSObjectObserverIface *ob)
return __type_info.name;
}
- DSObject::DSObject(std::string name) :
- __d_ptr(new DSObjectPrivate(this, name))
+ DSObjectPrivate& DSObjectPrivate::operator=(DSObjectPrivate &&p)
+ {
+ if (__p_ptr)
+ return *this;
+
+ __type_info.name = p.__type_info.name;
+ __p_ptr = p.__p_ptr;
+ __observers = std::move(p.__observers);
+ __properties = std::move(p.__properties);
+
+ p.__type_info.name.clear();
+ p.__p_ptr = nullptr;
+ p.__observers.clear();
+ p.__properties.clear();
+
+ return *this;
+ }
+
+ DSObject::DSObject()
{
+ __d_ptr = std::make_unique<DSObjectPrivate>(this);
}
DSObject::~DSObject()
{
return d_func()->getName();
}
+
+ DSObject::DSObject(std::unique_ptr<DSObjectPrivate> ptr)
+ {
+ __d_ptr = std::move(ptr);
+ }
} // namespace display_server
class DSObject {
public:
- explicit DSObject(std::string name = "WObject");
+ explicit DSObject();
virtual ~DSObject();
void attachDestroyObserver(DSObjectObserverIface *ob);
const DSPropertyVariant &getProperty(std::string key);
std::string getName(void);
-
+ protected:
+ DSObject(std::unique_ptr<DSObjectPrivate> ptr);
+ std::unique_ptr<DSObjectPrivate> __d_ptr;
private:
inline DSObjectPrivate *d_func()
{
{
return __d_ptr.get();
}
-
- std::unique_ptr<DSObjectPrivate> __d_ptr;
};
class DSObjectObserverIface {
class DSObjectPrivate {
public:
DSObjectPrivate() = delete;
- DSObjectPrivate(DSObject *p_ptr, std::string name = "default");
+ DSObjectPrivate(DSObject *p_ptr);
virtual ~DSObjectPrivate();
inline const DSObject *p_func() const
std::string getName(void);
+ DSObjectPrivate &operator=(DSObjectPrivate &&p); //move assignment
+
private:
struct
{