This repository has been archived on 2020-09-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
libs/pip/doc/examples/piobject.cpp
Бычков Андрей ba8bc27298 1
git-svn-id: svn://db.shs.com.ru/libs@1 a8b55f48-bf90-11e4-a774-851b48703e85
2015-02-28 21:28:53 +00:00

33 lines
821 B
C++

#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]