git-svn-id: svn://db.shs.com.ru/pip@6 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
48
doc/examples/picollection.cpp
Normal file
48
doc/examples/picollection.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "pip.h"
|
||||
//! [main]
|
||||
class ElementA: public PIObject {
|
||||
PIOBJECT(ElementA)
|
||||
// ...
|
||||
};
|
||||
ADD_NEW_TO_COLLECTION(ab_group, ElementA)
|
||||
|
||||
class ElementB: public PIObject {
|
||||
PIOBJECT(ElementB)
|
||||
// ...
|
||||
};
|
||||
ADD_NEW_TO_COLLECTION(ab_group, ElementB)
|
||||
|
||||
class ElementC: public PIObject {
|
||||
PIOBJECT(ElementC)
|
||||
// ...
|
||||
};
|
||||
ADD_NEW_TO_COLLECTION(c_group, ElementC)
|
||||
|
||||
class ElementD: public PIObject {
|
||||
PIOBJECT(ElementD)
|
||||
// ...
|
||||
};
|
||||
|
||||
int main() {
|
||||
ElementD * el_d = new ElementD();
|
||||
ADD_TO_COLLECTION(ab_group, el_d)
|
||||
|
||||
PIStringList gl = PICollection::groups();
|
||||
piCout << gl; // {"ab_group", "c_group"}
|
||||
piForeachC (PIString g, gl) {
|
||||
PIVector<const PIObject * > go = PICollection::groupElements(g);
|
||||
piCout << "group" << g << ":";
|
||||
piForeachC (PIObject * o, go)
|
||||
piCout << Tab << o->className();
|
||||
}
|
||||
|
||||
/*
|
||||
group ab_group :
|
||||
ElementA
|
||||
ElementB
|
||||
ElementD
|
||||
group c_group :
|
||||
ElementC
|
||||
*/
|
||||
};
|
||||
//! [main]
|
||||
Reference in New Issue
Block a user