git-svn-id: svn://db.shs.com.ru/libs@378 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2018-05-12 09:57:00 +00:00
parent e62e5a0c95
commit 56e250c150
15 changed files with 512 additions and 374 deletions

View File

@@ -0,0 +1,170 @@
#include "cdutils_interface.h"
#include "cdutils_core.h"
#include "piconfig.h"
#include "pifile.h"
using namespace CDUtils;
Interface::Interface(CDType::cdT type_) {
core = CDCore::instance();
s = core->root(type_);
//piCoutObj << (void*)this << core;
file_ = core->typeLetter(type_) + PIStringAscii(".dat");
file_size = 0;
}
bool Interface::test(int v) {
return s->test(v);
}
CDType & Interface::operator [](const PIString & name_) {
return (*s)[name_];
}
const CDType Interface::operator [](const PIString & name_) const {
return (*s)[name_];
}
CDType & Interface::operator [](const PIDeque<int> & path_) {
return (*s)[path_];
}
const CDType Interface::operator [](const PIDeque<int> & path_) const {
return (*s)[path_];
}
CDType & Interface::operator [](int v) {
//piCout << (void*)this << "[]" << core;
return (*s)[v];
}
const CDType Interface::operator [](int v) const {
//piCout << (void*)this << "[]" << core;
return (*s)[v];
}
CDSection & Interface::section(int v) {
// CDSection & ret = s->section(v);
// piCout << "[get section]" << v << ret.name;
return s->section(v);
}
const CDSection Interface::section(int v) const {
return s->section(v);
}
CDSection & Interface::section(const PIDeque<int> &path) {
PIDeque<int> spath = path;
CDSection * rs = s;
while (!spath.isEmpty()) {
rs = &(rs->section(spath.take_front()));
}
return *rs;
}
CDSection & Interface::root() {
return *s;
}
const CDSection & Interface::root() const {
return *s;
}
int Interface::count(bool recursive) const {
return s->count(recursive);
}
void Interface::setFileName(const PIString & _file) {
file_ = _file;
}
bool Interface::configure(const PIString & config) {
PIConfig conf(config, PIIODevice::ReadOnly);
PIConfig::Entry & e(conf.getValue(core->typeLetter(s->cd_type_)));
bool ret = false;
setFileName(e.getValue("file", file(), &ret));
return ret;
}
void Interface::reinitConnection(const PIString &configuration) {
core->init(configuration);
}
void Interface::startPing() {
core->startPing();
}
void Interface::write(PIIODevice * d) {
core->cd_write(s, d);
}
void Interface::read(PIIODevice * d) {
core->cd_read(s, d);
}
void Interface::parse(PIIODevice * d) {
core->cd_parse(s, d);
}
void Interface::update(PIIODevice * d, UpdateModeFlags mode) {
core->cd_update(s, d, mode);
}
void Interface::calculate() {
core->cd_calculate(s);
}
PIString Interface::appConfig() {
return core->appConfig();
}
PIString Interface::pultConfig() {
return core->pultConfig();
}
void Interface::readFile() {
if (file_.isEmpty()) return;
PIFile f(file_, PIIODevice::ReadOnly);
read(&f);
file_size = f.size();
}
void Interface::writeFile() {
if (file_.isEmpty()) return;
PIFile f(file_, PIIODevice::ReadWrite);
f.clear();
write(&f);
file_size = f.size();
}
bool Interface::inProgress() {
return core->inProgress();
}