git-svn-id: svn://db.shs.com.ru/libs@380 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
55
cd_utils/cdutils_c.cpp
Normal file
55
cd_utils/cdutils_c.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "cdutils_c.h"
|
||||
#include "cdutils_core.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
CInterface C;
|
||||
|
||||
|
||||
CInterface::CInterface(): Interface(CDType::cdC) {
|
||||
CONNECTU(core, C_Sended, this, sended);
|
||||
CONNECTU(core, C_SendFail, this, sendFailed);
|
||||
CONNECTU(core, C_Received, this, received);
|
||||
CONNECTU(core, C_ReceiveFail, this, receiveFailed);
|
||||
}
|
||||
|
||||
|
||||
void CInterface::send() {
|
||||
core->C_Send();
|
||||
}
|
||||
|
||||
|
||||
void CInterface::request() {
|
||||
core->C_Request();
|
||||
}
|
||||
|
||||
|
||||
void CInterface::sendCommand(const CDType & c) {
|
||||
core->sendCommand(c);
|
||||
}
|
||||
|
||||
|
||||
void CInterface::connect(const CDType & c, PIObject * o, Handler eh) {
|
||||
core->registerCHandler(c, o, eh);
|
||||
}
|
||||
|
||||
|
||||
void CInterface::autoConnect(PIObject * o, const PIString & prefix) {
|
||||
if (!o) return;
|
||||
PIString cn = o->className();
|
||||
if (!PIObject::__meta_data().contains(cn)) return;
|
||||
PIMap<PIString, Handler> eh_map;
|
||||
PIObject::__MetaData & md(PIObject::__meta_data()[cn]);
|
||||
PIMap<const void * , __MetaFunc>::const_iterator it;
|
||||
for (it = md.eh_func.constBegin(); it != md.eh_func.constEnd(); ++it) {
|
||||
eh_map[it.value().func_name] = (Handler)it.value().addr;
|
||||
//piCout << "func" << it.value().func_name;
|
||||
}
|
||||
PIVector<CDType * > cl = C.root().children();
|
||||
piForeachC (CDType * c, cl) {
|
||||
PIString cp = prefix + c->pathString().join("_");
|
||||
if (cp.isEmpty()) continue;
|
||||
if (!eh_map.contains(cp)) continue;
|
||||
connect(*c, o, eh_map[cp]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user