-#include "../core/WObject.h"
-#include "../core/WSignal.h"
-#include "../core/WRefBase.h"
+#include "../lib/DSObject.h"
+#include "../lib/DSSignal.h"
+#include "../lib/DSRefBase.h"
#include <string>
+/* SAMPLE RESULT
+construct Sender sender
+construct Sender sender2
+construct Receiver receiver1
+construct Receiver receiver2
+slotA invoked! a:1234
+slotA2 invoked! a:1234
+slotB invoked! a:45.67
+Lambda slot invoked! val: 45.67
+destruct Receiver(ref: 0) receiver2
+slotB invoked! a:5678
+slotA invoked! a:90
+destruct Sender sender
+destruct Sender sender2
+destruct Receiver(ref: 1) receiver1
+ */
+
using namespace TizenDisplayServer;
-using SignalAType = WSignal<int>;
-using SignalBType = WSignal<double>;
+using SignalAType = DSSignal<int>;
+using SignalBType = DSSignal<double>;
-class Sender : public WObject
+class Sender : public DSObject
{
public:
- Sender() : WObject("Sender"){ std::cout << "construct Sender" << std::endl;}
- Sender(std::string name) : WObject(name) {std::cout << "construct Sender " << name << std::endl;}
+ Sender() : DSObject("Sender"){ std::cout << "construct Sender" << std::endl;}
+ Sender(std::string name) : DSObject(name) {std::cout << "construct Sender " << name << std::endl;}
~Sender(){ std::cout << "destruct Sender " << getName() << std::endl;}
struct SignalA : public SignalAType {
} signalB;
};
-class Receiver : public WObject, public WRefBase {
+class Receiver : public DSObject, public DSRefBase {
public:
- Receiver() : WObject("Receiver"), WRefBase() { std::cout << "construct Receiver" << std::endl;}
- Receiver(std::string name) : WObject(name), WRefBase() { std::cout << "construct Receiver " << name << std::endl;}
+ Receiver() : DSObject("Receiver"), DSRefBase() { std::cout << "construct Receiver" << std::endl;}
+ Receiver(std::string name) : DSObject(name), DSRefBase() { std::cout << "construct Receiver " << name << std::endl;}
~Receiver() { std::cout << "destruct Receiver(ref: " << getref() << ") " << getName() << std::endl; }
static void slotA(int a) { std::cout << "slotA invoked! a:" << a << std::endl; };
+++ /dev/null
-#ifndef WCALLBACKIFACE_H
-# define WCALLBACKIFACE_H
-namespace TizenDisplayServer{
- struct WCallbackIface{
- WCallbackIface(){}
- WCallbackIface(const WCallbackIface& cp){
- }
- };
-
-}
-#else
-#endif
\ No newline at end of file
+++ /dev/null
-#include "WObjectPrivate.h"
-#include "WObject.h"
-
-namespace TizenDisplayServer{
- WObjectPrivate::WObjectPrivate(WObject *p_ptr, std::string name) : p_ptr(p_ptr)
- {
- type_info.name = name;
- }
-
- WObjectPrivate::~WObjectPrivate()
- {
- }
-
- void WObjectPrivate::attachDestroyObserver(WObjectObserverIface *ob)
- {
- observers.push_back(ob);
- }
-
- void WObjectPrivate::detachDestroyObserver(WObjectObserverIface *ob)
- {
- observers.remove(ob);
- }
-
- bool WObjectPrivate::setProperty(std::string key, WProperty property)
- {
- }
-
- WProperty& WObjectPrivate::getProperty(std::string key)
- {
- }
-
- void WObjectPrivate::destroyNotify(void)
- {
- for (WObjectObserverIface* ob : observers)
- {
- ob->destroyed(p_ptr);
- }
- observers.clear();
- }
-
- std::string WObjectPrivate::getName(void)
- {
- return type_info.name;
- }
-
- WObject::WObject(std::string name)
- {
- std::unique_ptr<WObjectPrivate> ptr(new WObjectPrivate(this, name));
- d_ptr = std::move(ptr);
- }
-
- WObject::~WObject(){
- destroyNotify();
- }
-
- void WObject::destroyNotify(void)
- {
- d_func()->destroyNotify();
- }
-
- void WObject::attachDestroyObserver(WObjectObserverIface *ob)
- {
- d_func()->attachDestroyObserver(ob);
- }
-
- void WObject::detachDestroyObserver(WObjectObserverIface *ob)
- {
- d_func()->detachDestroyObserver(ob);
- }
-
- bool WObject::setProperty(std::string key, WProperty property)
- {
-
- }
-
- WProperty& WObject::getProperty(std::string key)
- {
-
- }
-
- std::string WObject::getName(void)
- {
- return d_func()->getName();
- }
-}
+++ /dev/null
-#ifndef WOBJECT_H
-# define WOBJECT_H
-
-#include "WObjectPrivate.h"
-#include "WProperty.h"
-#include <memory>
-#include <vector>
-#include <list>
-#include <iostream>
-#include <string>
-
-namespace TizenDisplayServer{
-class WObjectPrivate;
-class WObjectObserverIface;
-class WProperty;
-
-class WObject {
- std::unique_ptr<WObjectPrivate> d_ptr;
-
- inline WObjectPrivate* d_func() { return d_ptr.get(); }
- inline const WObjectPrivate* d_func() const { return d_ptr.get(); }
-
- public:
- WObject(std::string name = "WObject");
- virtual ~WObject();
-
- void attachDestroyObserver(WObjectObserverIface *ob);
- void detachDestroyObserver(WObjectObserverIface *ob);
- void destroyNotify(void);
-
- bool setProperty(std::string key, WProperty property);
- WProperty& getProperty(std::string key);
-
- std::string getName(void);
-};
-
-class WObjectObserverIface {
- public:
- WObjectObserverIface() {}
- virtual ~WObjectObserverIface() {}
- virtual void destroyed(WObject *obj) = 0;
-};
-
-}
-#else
-#endif
\ No newline at end of file
+++ /dev/null
-#ifndef WOBJECTPRIVATE_H
-# define WOBJECTPRIVATE_H
-
-#include "WObject.h"
-#include "WProperty.h"
-#include <iostream>
-#include <list>
-#include <unordered_map>
-#include <string>
-
-namespace TizenDisplayServer{
-
-class WObject;
-class WObjectObserverIface;
-
-class WObjectPrivate {
-
- struct TypeInfo{
- std::string name;
- };
-
- WObject *p_ptr;
-
- std::list<WObjectObserverIface*> observers;
- std::unordered_map<std::string, WProperty> properties;
- TypeInfo type_info;
-
- public:
- WObjectPrivate() = delete;
- WObjectPrivate(WObject *p_ptr, std::string name = "default");
- ~WObjectPrivate();
-
- inline const WObject *p_func() const{ return p_ptr;}
-
- void attachDestroyObserver(WObjectObserverIface *ob);
- void detachDestroyObserver(WObjectObserverIface *ob);
- bool setProperty(std::string key, WProperty property);
- WProperty& getProperty(std::string key);
- void destroyNotify();
-
- std::string getName(void);
-};
-}
-#else
-#endif
\ No newline at end of file
+++ /dev/null
-#ifndef WPROPERTY_H
-# define WPROPERTY_H
-namespace TizenDisplayServer{
- class WProperty {
- public:
- WProperty(){}
- virtual ~WProperty() {}
- };
-}
-
-#else
-#endif
\ No newline at end of file
--- /dev/null
+#ifndef DSCALLBACKIFACE_H
+# define DSCALLBACKIFACE_H
+namespace TizenDisplayServer{
+ struct DSCallbackIface{
+ DSCallbackIface(){}
+ DSCallbackIface(const DSCallbackIface& cp){
+ }
+ };
+
+}
+#else
+#endif /* DSCALLBACKIFACE_H */
--- /dev/null
+#include "DSObjectPrivate.h"
+#include "DSObject.h"
+
+namespace TizenDisplayServer{
+ DSObjectPrivate::DSObjectPrivate(DSObject *p_ptr, std::string name) : p_ptr(p_ptr)
+ {
+ type_info.name = name;
+ }
+
+ DSObjectPrivate::~DSObjectPrivate()
+ {
+ }
+
+ void DSObjectPrivate::attachDestroyObserver(DSObjectObserverIface *ob)
+ {
+ observers.push_back(ob);
+ }
+
+ void DSObjectPrivate::detachDestroyObserver(DSObjectObserverIface *ob)
+ {
+ observers.remove(ob);
+ }
+
+ bool DSObjectPrivate::setProperty(std::string key, DSProperty&& property)
+ {
+
+ }
+
+ DSProperty& DSObjectPrivate::getProperty(std::string key)
+ {
+ }
+
+ void DSObjectPrivate::destroyNotify(void)
+ {
+ for (DSObjectObserverIface* ob : observers)
+ {
+ ob->destroyed(p_ptr);
+ }
+ observers.clear();
+ }
+
+ std::string DSObjectPrivate::getName(void)
+ {
+ return type_info.name;
+ }
+
+ DSObject::DSObject(std::string name)
+ {
+ std::unique_ptr<DSObjectPrivate> ptr(new DSObjectPrivate(this, name));
+ d_ptr = std::move(ptr);
+ }
+
+ DSObject::~DSObject(){
+ destroyNotify();
+ }
+
+ void DSObject::destroyNotify(void)
+ {
+ d_func()->destroyNotify();
+ }
+
+ void DSObject::attachDestroyObserver(DSObjectObserverIface *ob)
+ {
+ d_func()->attachDestroyObserver(ob);
+ }
+
+ void DSObject::detachDestroyObserver(DSObjectObserverIface *ob)
+ {
+ d_func()->detachDestroyObserver(ob);
+ }
+
+ bool DSObject::setProperty(std::string key, DSPropertyVariant& data, DSPropertyType type)
+ {
+ }
+
+ DSPropertyVariant& DSObject::getProperty(std::string key)
+ {
+
+ }
+
+ std::string DSObject::getName(void)
+ {
+ return d_func()->getName();
+ }
+}
--- /dev/null
+#ifndef DSOBJECT_H
+# define DSOBJECT_H
+
+#include "DSObjectPrivate.h"
+#include "DSProperty.h"
+#include <memory>
+#include <iostream>
+#include <string>
+
+namespace TizenDisplayServer{
+class DSObjectPrivate;
+class DSObjectObserverIface;
+class DSProperty;
+
+class DSObject {
+ std::unique_ptr<DSObjectPrivate> d_ptr;
+
+ inline DSObjectPrivate* d_func() { return d_ptr.get(); }
+ inline const DSObjectPrivate* d_func() const { return d_ptr.get(); }
+
+ public:
+ DSObject(std::string name = "WObject");
+ virtual ~DSObject();
+
+ void attachDestroyObserver(DSObjectObserverIface *ob);
+ void detachDestroyObserver(DSObjectObserverIface *ob);
+ void destroyNotify(void);
+
+ bool setProperty(std::string key, DSPropertyVariant& data, DSPropertyType type);
+ DSPropertyVariant& getProperty(std::string key);
+
+ std::string getName(void);
+};
+
+class DSObjectObserverIface {
+ protected:
+ DSObjectObserverIface() {}
+ virtual ~DSObjectObserverIface() {}
+
+ public:
+ virtual void destroyed(DSObject *obj) = 0;
+};
+
+}
+#else
+#endif /* DSOBJECT_H */
--- /dev/null
+#ifndef DSOBJECTPRIVATE_H
+# define DSOBJECTPRIVATE_H
+
+#include "DSObject.h"
+#include "DSProperty.h"
+#include <iostream>
+#include <list>
+#include <unordered_map>
+#include <string>
+
+namespace TizenDisplayServer{
+
+class DSObject;
+class DSObjectObserverIface;
+
+class DSObjectPrivate {
+
+ struct {
+ std::string name;
+ }type_info;
+
+ DSObject *p_ptr;
+
+ std::list<DSObjectObserverIface*> observers;
+ std::unordered_map<std::string, DSProperty> properties;
+
+ public:
+ DSObjectPrivate() = delete;
+ DSObjectPrivate(DSObject *p_ptr, std::string name = "default");
+ virtual ~DSObjectPrivate();
+
+ inline const DSObject *p_func() const{ return p_ptr;}
+
+ void attachDestroyObserver(DSObjectObserverIface *ob);
+ void detachDestroyObserver(DSObjectObserverIface *ob);
+ void destroyNotify();
+
+ bool setProperty(std::string key, DSProperty&& property);
+ DSProperty& getProperty(std::string key);
+
+ std::string getName(void);
+};
+}
+#else
+#endif /* DSOBJECTPRIVATE_H */
--- /dev/null
+#include "DSProperty.h"
+
+namespace TizenDisplayServer{
+ DSProperty::DSProperty(std::string _key, DSPropertyVariant& _data, DSPropertyType _type) : key(_key), type(_type)
+ {
+ switch(_type)
+ {
+ //copy case
+ case DSPropertyType::INTEGER:
+ case DSPropertyType::DOUBLE:
+ case DSPropertyType::FLOAT:
+ case DSPropertyType::STRING:
+ data = _data; //copy
+ break;
+ case DSPropertyType::OBJECT:
+ data = &_data; //address
+ break;
+ default:
+ break;
+ }
+ }
+
+ DSProperty::~DSProperty()
+ {
+ }
+}
--- /dev/null
+#ifndef DSPROPERTY_H
+# define DSPROPERTY_H
+#include <string>
+#include <variant>
+
+namespace TizenDisplayServer{
+ using DSPropertyType = enum type{
+ NONE,
+ INTEGER,
+ FLOAT,
+ DOUBLE,
+ STRING,
+ OBJECT,
+ };
+
+ using DSPropertyVariant = std::variant<int,
+ float,
+ double,
+ std::string,
+ void*>;
+
+ class DSProperty
+ {
+ private:
+ std::string key;
+ DSPropertyVariant data;
+ DSPropertyType type;
+
+ public:
+ DSProperty(std::string key, DSPropertyVariant& data, DSPropertyType type);
+ virtual ~DSProperty();
+ };
+}
+
+#else
+#endif /* DSPROPERTY_H */
--- /dev/null
+#ifndef DSPROPERTYPRIVATE_H
+# define DSPROPERTYPRIVATE_H
+#else
+#endif /* DSPROPERTYPRIVATE_H */
-#ifndef WREFBASE_H
-# define WREFBASE_H
+#ifndef DSREFBASE_H
+# define DSREFBASE_H
namespace TizenDisplayServer{
-class WRefBase {
+class DSRefBase {
int mCount;
public:
- WRefBase() : mCount(1) {}
- virtual ~WRefBase() {}
+ DSRefBase() : mCount(1) {}
+ virtual ~DSRefBase() {}
void ref() { ++mCount; }
void unref() {if (--mCount == 0) delete this;}
}
#else
-#endif
\ No newline at end of file
+#endif /* DSREFBASE_H */
-#include "WSignal.h"
+#include "DSSignal.h"
#include <type_traits>
namespace TizenDisplayServer {
- void WSlotsObserver::addSlot(WObject *slot)
+ void DSSlotsObserver::addSlot(DSObject *slot)
{
slots.push_back(slot);
}
- void WSlotsObserver::destroyed(WObject *slot)
+ void DSSlotsObserver::destroyed(DSObject *slot)
{
slots.remove(slot);
if (slots.empty())
delete this;
}
-}
\ No newline at end of file
+}
-#ifndef WSIGNAL_H
-# define WSIGNAL_H
-#include "WObject.h"
+#ifndef DSSIGNAL_H
+# define DSSIGNAL_H
+
+#include "DSObject.h"
#include <list>
#include <memory>
#include <iostream>
#include <string>
namespace TizenDisplayServer{
- class WSlotsObserver : public WObjectObserverIface {
+ class DSSlotsObserver : public DSObjectObserverIface {
protected:
- std::list<WObject *> slots;
+ std::list<DSObject *> slots;
public:
- WSlotsObserver(){}
- ~WSlotsObserver(){}
+ DSSlotsObserver(){}
+ ~DSSlotsObserver(){}
- virtual void destroyed(WObject *obj);
- virtual void addSlot(WObject *slot);
+ virtual void destroyed(DSObject *obj);
+ virtual void addSlot(DSObject *slot);
};
template <typename... Args>
- class WSlotConnection : public WSlotsObserver{
+ class DSSlotConnection : public DSSlotsObserver{
//TODO: make callback as callback iface
- //std::unique_ptr<WCallbackIface> callback;
+ //std::unique_ptr<DSCallbackIface> callback;
void (*callback)(Args...);
- template <typename... _Args> friend class WSignal;
+ template <typename... _Args> friend class DSSignal;
public:
- WSlotConnection() {}
- WSlotConnection(WObject *slot, void (*func) (Args...)) : callback(func) {
+ DSSlotConnection() {}
+ DSSlotConnection(DSObject *slot, void (*func) (Args...)) : callback(func) {
//TODO: make callback as callback iface
- //std::unique_ptr<WCallbackIface> ptr(new WCallbackIface(func));
+ //std::unique_ptr<DSCallbackIface> ptr(new DSCallbackIface(func));
//callback = std::move(ptr);
addSlot(slot);
}
- virtual ~WSlotConnection()
+ virtual ~DSSlotConnection()
{
for (auto &&slot : slots)
slot->detachDestroyObserver(this);
slots.clear();
}
- void addSlot (WObject *slot) override
+ void addSlot (DSObject *slot) override
{
slots.push_back(slot);
slot->attachDestroyObserver(this);
}
- void destroyed(WObject *slot) override
+ void destroyed(DSObject *slot) override
{
slots.remove(slot);
if (slots.empty())
{
- //TODO: detete from WSignal connections list with guarded pointer
+ //TODO: delete from DSSignal connections list with [guard pointer]
}
}
};
template <typename... Args>
- class WSignal {
- std::list<std::unique_ptr<WSlotConnection<Args...>>> connections;
- WSlotConnection<Args...> *findcon(void (*func)(Args...)) {
+ class DSSignal {
+ std::list<std::unique_ptr<DSSlotConnection<Args...>>> connections;
+ DSSlotConnection<Args...> *findcon(void (*func)(Args...)) {
for (auto&& con : connections)
{
if (con->callback == func)
}
public:
- WSignal() {}
- virtual ~WSignal() {}
+ DSSignal() {}
+ virtual ~DSSignal() {}
- WSignal<Args...>& operator()(void) { return *this; } // functor
+ DSSignal<Args...>& operator()(void) { return *this; } // functor
- void connect(WObject *slot, void (*func)(Args...))
+ void connect(DSObject *slot, void (*func)(Args...))
{
if ((!slot) || (!func))
return;
}
else
{
- connections.emplace_back(new WSlotConnection<Args...>(slot, func));
+ connections.emplace_back(new DSSlotConnection<Args...>(slot, func));
}
}
};
}
#else
-#endif
\ No newline at end of file
+#endif /* DSSIGNAL_H */