30.11.2013 - New PICollection namespace, Android support, my own PIVector implementation
This commit is contained in:
46
piobject.h
46
piobject.h
@@ -31,7 +31,7 @@
|
||||
#ifdef DOXYGEN
|
||||
|
||||
|
||||
/// \relatesalso PIObject \brief you should use this macro after class declaration to use EVENT and EVENT_HANDLER
|
||||
/// \relatesalso PIObject \brief you should use this macro after class declaration to use EVENT and EVENT_HANDLER and correct piCoutObj output
|
||||
#define PIOBJECT(name)
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@
|
||||
#else
|
||||
|
||||
|
||||
#define PIOBJECT(obj) typedef obj __PIObject__; public: virtual const char * debugName() const {return #obj;} private:
|
||||
#define PIOBJECT(obj) typedef obj __PIObject__; public: virtual const char * className() const {return #obj;} private:
|
||||
|
||||
#define EVENT_HANDLER0(ret, name) static ret __stat_eh_##name##__(void * o) {return ((__PIObject__*)o)->name();} ret name()
|
||||
#define EVENT_HANDLER1(ret, name, a0, n0) static ret __stat_eh_##name##__(void * o, a0 n0) {return ((__PIObject__*)o)->name(n0);} ret name(a0 n0)
|
||||
@@ -221,49 +221,22 @@
|
||||
|
||||
typedef void (*Handler)(void * );
|
||||
|
||||
/** \brief This is base class for any classes which use events -> handlers mechanism.
|
||||
* \details
|
||||
* \section PIObject_sec0 Events and Event handlers
|
||||
* %PIObject provide notification mechanism similar Qt but implemented
|
||||
* on language capabilities without any special preprocessors or compilers.
|
||||
* Any class inherits PIObject should use macro \a PIOBJECT() immediate
|
||||
* after declaration to proper compile.
|
||||
*
|
||||
* Event is a some abstract event that can be raised at any time.
|
||||
* Event is a function but declared with special macro \a EVENT().
|
||||
* To raise event simply execute event function.
|
||||
*
|
||||
* Event handler is a function but declared with special macro
|
||||
* \a EVENT_HANDLER(). You can use event handlers as ordinary functions.
|
||||
*
|
||||
* Main goal of this mechanism is perform abstract connections between
|
||||
* various objects. This functionality provide macro \a CONNECT() which
|
||||
* connect some event of first object to some event handler or event of
|
||||
* second object. Each event can be connected any times to any event handlers.
|
||||
*
|
||||
* Example: \snippet piobject.cpp main
|
||||
* Result:
|
||||
\code{.cpp}
|
||||
handler B: 2 , 0.5
|
||||
handler A: event to handler
|
||||
handler A: event to event
|
||||
\endcode
|
||||
*/
|
||||
class PIP_EXPORT PIObject
|
||||
{
|
||||
friend class PIObjectManager;
|
||||
public:
|
||||
|
||||
//! Contructs PIObject with name "name"
|
||||
PIObject(const PIString & name = PIString()) {piMonitor.objects++; setName(name); dname_ = "PIObject"; objects << this; debug_ = true;}
|
||||
~PIObject() {piMonitor.objects--; objects.removeAll(this);}
|
||||
PIObject(const PIString & name = PIString()) {piMonitor.objects++; setName(name); objects << this; debug_ = true;}
|
||||
|
||||
virtual ~PIObject() {piMonitor.objects--; objects.removeAll(this);}
|
||||
|
||||
|
||||
//! Returns object name
|
||||
const PIString & name() const {return name_;}
|
||||
|
||||
//! Returns object class name for debug
|
||||
virtual const char * debugName() const {return dname_.data();}
|
||||
//! Returns object class name
|
||||
virtual const char * className() const {return "PIObject";}
|
||||
|
||||
//! Return if debug of this object is active
|
||||
bool debug() const {return debug_;}
|
||||
@@ -272,9 +245,6 @@ public:
|
||||
//! Set object name
|
||||
void setName(const PIString & name) {name_ = name;}
|
||||
|
||||
//! Set object debug active
|
||||
void setDebugName(const PIString & name) {dname_ = name;}
|
||||
|
||||
//! Set object debug active
|
||||
void setDebug(bool debug) {debug_ = debug;}
|
||||
|
||||
@@ -493,7 +463,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
PIString name_, dname_;
|
||||
PIString name_;
|
||||
bool debug_;
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user