git-svn-id: svn://db.shs.com.ru/pip@6 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
32
doc/examples/piobject.cpp
Normal file
32
doc/examples/piobject.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "pip.h"
|
||||
|
||||
//! [main]
|
||||
class ObjectA: public PIObject {
|
||||
PIOBJECT(ObjectA)
|
||||
public:
|
||||
EVENT_HANDLER1(void, handlerA, const PIString & , str) {piCoutObj << "handler A:" << str;}
|
||||
EVENT2(eventA2, int, i, float, f);
|
||||
EVENT1(eventA1, const PIString & , str);
|
||||
};
|
||||
|
||||
class ObjectB: public PIObject {
|
||||
PIOBJECT(ObjectB)
|
||||
public:
|
||||
EVENT_HANDLER2(void, handlerB, int, i, float, f) {piCoutObj << "handler B:" << i << "," << f;}
|
||||
EVENT1(eventB, PIString, str);
|
||||
};
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
ObjectA obj_a;
|
||||
ObjectB obj_b;
|
||||
|
||||
CONNECT2(void, int, float, &obj_a, eventA2, &obj_b, handlerB);
|
||||
obj_a.eventA2(2, 0.5);
|
||||
|
||||
CONNECT1(void, PIString, &obj_b, eventB, &obj_a, handlerA);
|
||||
obj_b.eventB("event to handler");
|
||||
|
||||
CONNECT1(void, PIString, &obj_a, eventA1, &obj_b, eventB);
|
||||
obj_a.eventA1("event to event");
|
||||
};
|
||||
//! [main]
|
||||
Reference in New Issue
Block a user