146 lines
2.7 KiB
C++
146 lines
2.7 KiB
C++
#include "cdutils_k.h"
|
|
#include "cdutils_core.h"
|
|
#include "piconfig.h"
|
|
#include "pifile.h"
|
|
|
|
using namespace CDUtils;
|
|
|
|
|
|
KInterface::KInterface() {
|
|
core = CDCore::instance();
|
|
//piCoutObj << core;
|
|
k_file = PIStringAscii("k.dat");
|
|
k_file_size = 0;
|
|
CONNECTU(core, K_Sended, this, sended);
|
|
CONNECTU(core, K_SendFail, this, sendFailed);
|
|
CONNECTU(core, K_Received, this, received);
|
|
CONNECTU(core, K_ReceiveFail, this, receiveFailed);
|
|
CONNECTU(core, K_KeepNamesRequest, this, keepNamesRequest);
|
|
}
|
|
|
|
|
|
bool KInterface::test(int v) {
|
|
return core->k_.test(v);
|
|
}
|
|
|
|
|
|
CDType & KInterface::operator [](int v) {
|
|
return core->k_[v];
|
|
}
|
|
|
|
|
|
const CDType KInterface::operator [](int v) const {
|
|
return core->k_[v];
|
|
}
|
|
|
|
|
|
CDSection & KInterface::section(int v) {
|
|
// CDSection & ret = core->k_.section(v);
|
|
// piCout << "[get section]" << v << ret.name;
|
|
return core->k_.section(v);
|
|
}
|
|
|
|
const CDSection KInterface::section(int v) const {
|
|
return core->k_.section(v);
|
|
}
|
|
|
|
|
|
CDSection & KInterface::section(const PIDeque<int> &path) {
|
|
PIDeque<int> spath = path;
|
|
CDSection * rs = &core->k_;
|
|
while (!spath.isEmpty()) {
|
|
rs = &rs->section(spath.take_front());
|
|
}
|
|
return *rs;
|
|
}
|
|
|
|
|
|
CDSection & KInterface::root() {
|
|
return core->k_;
|
|
}
|
|
|
|
|
|
const CDSection KInterface::root() const {
|
|
return core->k_;
|
|
}
|
|
|
|
|
|
int KInterface::count(bool recursive) const {
|
|
return core->k_.count(recursive);
|
|
}
|
|
|
|
|
|
void KInterface::send() {
|
|
core->K_Send();
|
|
}
|
|
|
|
void KInterface::request() {
|
|
core->K_Request();
|
|
}
|
|
|
|
|
|
bool KInterface::configure(const PIString & config, const PIString & sect) {
|
|
PIConfig conf(config, PIIODevice::ReadOnly);
|
|
PIConfig::Entry & e(conf.getValue(sect));
|
|
bool ret = false;
|
|
k_file = e.getValue("file", "k.dat", &ret);
|
|
return ret;
|
|
}
|
|
|
|
|
|
void KInterface::reinitConnection(const PIString &configuration) {
|
|
core->reinitConnection(configuration);
|
|
}
|
|
|
|
|
|
void KInterface::write(PIIODevice * d) {
|
|
core->k_write(d);
|
|
}
|
|
|
|
|
|
void KInterface::read(PIIODevice * d) {
|
|
core->k_read(d);
|
|
}
|
|
|
|
|
|
void KInterface::parse(PIIODevice * d) {
|
|
core->k_parse(d);
|
|
}
|
|
|
|
|
|
void KInterface::update(PIIODevice * d) {
|
|
core->k_update(d);
|
|
}
|
|
|
|
|
|
PIString KInterface::appConfig() {
|
|
return core->appConfig();
|
|
}
|
|
|
|
|
|
PIString KInterface::pultConfig() {
|
|
return core->pultConfig();
|
|
}
|
|
|
|
|
|
void KInterface::readFile() {
|
|
if (k_file.isEmpty()) return;
|
|
PIFile f(k_file, PIIODevice::ReadOnly);
|
|
read(&f);
|
|
k_file_size = f.size();
|
|
}
|
|
|
|
|
|
void KInterface::writeFile() {
|
|
if (k_file.isEmpty()) return;
|
|
PIFile f(k_file, PIIODevice::ReadWrite);
|
|
f.clear();
|
|
write(&f);
|
|
k_file_size = f.size();
|
|
}
|
|
|
|
|
|
bool KInterface::inProgress() {
|
|
return core->inProgress();
|
|
}
|