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

This commit is contained in:
2017-05-29 10:56:01 +00:00
parent 63d55df859
commit b8ff28ab82
12 changed files with 194 additions and 72 deletions

View File

@@ -121,7 +121,7 @@ void CDCore::k_parse(PIIODevice * d) {
void CDCore::k_update(PIIODevice * d) {
CDSection uk = k_;
k_parse(d);
bool kn = false;
bool kn = true;
if (!uk.isEmpty())
if (!uk.isSameStructure(k_)) {
piCout << "ask for save names";
@@ -131,6 +131,7 @@ void CDCore::k_update(PIIODevice * d) {
//piCout << k_.count() << uk.count();
k_ = uk;
k_.makePath();
k_.calculate();
K_ChangedGlobal();
}
@@ -188,6 +189,13 @@ void CDUtils::CDCore::dataReceived(const PIString & from, const PIByteArray & da
}
CDCore * CDCore::instance() {
/*static CDCore * ret = new CDCore();
return ret;*/
return __Core_Initializer__::__instance__;
}
void CDCore::K_Send() {
piCoutObj << "K_Send";
PIByteArray ba;

View File

@@ -28,7 +28,7 @@ class CDCore: public PIObject
friend class CDSection;
friend class KInterface;
public:
static CDCore * instance() {return __Core_Initializer__::__instance__;}
static CDCore * instance();
EVENT(K_Sended)
EVENT(K_SendFail)

View File

@@ -5,10 +5,12 @@
using namespace CDUtils;
KInterface K;
KInterface::KInterface() {
core = CDCore::instance();
//piCoutObj << core;
//piCoutObj << (void*)this << core;
k_file = PIStringAscii("k.dat");
k_file_size = 0;
CONNECTU(core, K_Sended, this, sended);
@@ -35,11 +37,13 @@ CDType & KInterface::operator [](const PIString & name_) {
CDType & KInterface::operator [](int v) {
//piCout << (void*)this << "[]" << core;
return core->k_[v];
}
const CDType KInterface::operator [](int v) const {
//piCout << (void*)this << "[]" << core;
return core->k_[v];
}

View File

@@ -65,8 +65,8 @@ private:
};
static KInterface K;
}
extern CDUtils::KInterface K;
#endif // CDUTILS_K_H

View File

@@ -167,7 +167,7 @@ CDSection CDParser::parse(PIIODevice * d, int cdsection_type) {
comment.cutLeft(en.size_s() + 2).trim();
ck.setEnumValues(sections.value(en).enumValues());
ck.setComment(comment);
piCout << "enum" << en << ck.enumValues();
//piCout << "enum" << en << ck.enumValues();
}
}
cs[cev] = ck;

View File

@@ -301,31 +301,29 @@ void CDSection::write(PIIODevice * d, const PIString & prefix) {
if (k.isEmpty() && s.isEmpty()) return;
// piCout << "[CDSection] write start";
PIString l;
if (!k.isEmpty()) {
if (prefix.isEmpty()) l = "[k]";
else l = "[" + prefix + ".k]";
l += "\n";
if (prefix.isEmpty()) l = "[k]";
else l = "[" + prefix + ".k]";
l += "\n";
d->write(l.toUTF8());
l = "name = " + name + " \n";
d->write(l.toUTF8());
l = "alias = " + alias + " \n";
d->write(l.toUTF8());
PIMap<int, CDType>::iterator i;
for (i = k.begin(); i != k.end(); ++i) {
CDType & ck(i.value());
l.clear(); l << ck.index() << ".f = " << ck.formula() << " #s " << ck.comment() << " \n";
d->write(l.toUTF8());
l = "name = " + name + " \n";
l.clear(); l << ck.index() << ".v = " << ck.value() << " #" << ck.type() << " " << ck.name() << " \n";
d->write(l.toUTF8());
l = "alias = " + alias + " \n";
d->write(l.toUTF8());
PIMap<int, CDType>::iterator i;
for (i = k.begin(); i != k.end(); ++i) {
CDType & ck(i.value());
l.clear(); l << ck.index() << ".f = " << ck.formula() << " #s " << ck.comment() << " \n";
if (!ck.enumValues().enum_list.isEmpty()) {
l.clear(); l << ck.index() << ".ev = {";
//PIVector<CDType::Enumerator> el = ck.enumValues();
piForeachC (PIVariantTypes::Enumerator & e, ck.enumValues().enum_list)
l << e.value << " - " << e.name << ", ";
l.cutRight(2);
l << "} \n";
d->write(l.toUTF8());
l.clear(); l << ck.index() << ".v = " << ck.value() << " #" << ck.type() << " " << ck.name() << " \n";
d->write(l.toUTF8());
if (!ck.enumValues().enum_list.isEmpty()) {
l.clear(); l << ck.index() << ".ev = {";
//PIVector<CDType::Enumerator> el = ck.enumValues();
piForeachC (PIVariantTypes::Enumerator & e, ck.enumValues().enum_list)
l << e.value << " - " << e.name << ", ";
l.cutRight(2);
l << "} \n";
d->write(l.toUTF8());
}
}
}
if (!s.isEmpty()) {