MCPcopy Create free account
hub / github.com/NatLabRockies/SAM / OnModify

Method OnModify

src/defmgr.cpp:569–705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

567}
568
569void DefaultsManager::OnModify( wxCommandEvent & )
570{
571 ClearLog();
572
573
574 bool en_change = m_changeType->GetValue();
575 int datatype = m_value->GetType();
576 VarValue value = m_value->Get();
577
578 for (int i=0;i<(int)m_configList->GetCount();i++) {
579 if (!m_configList->IsChecked(i)) continue;
580
581 wxString file(GetDefaultsFile(m_techList[i], m_finList[i]));
582 std::vector<VarTable> vt;
583 ConfigInfo* ci = SamApp::Config().Find(m_techList[i], m_finList[i]);
584 vt.resize(ci->Technology.size());
585
586 if (!wxFileExists(file)) {
587 Log("file read error: " + file);
588 continue;
589 }
590
591 if (SamApp::VarTablesFromJSONFile(ci, vt, file.ToStdString())) {
592 wxString name(m_varName->GetValue());
593 wxString varName = name;
594 size_t ndxHybrid = 0;
595 if (ci->Technology.size() > 1) {
596 // split hybrid name and match with Technology name or use "Hybrid" for remainder
597 wxArrayString as = wxSplit(name, '_');
598 for (size_t j = 0; j < ci->Technology.size(); j++) {
599 if (ci->Technology[j].Lower() == as[0]) {
600 ndxHybrid = j;
601 varName = name.Right(name.length() - (as[0].length() + 1));
602 }
603 }
604 }
605
606 bool needs_write = false;
607
608 VarValue* vv = vt[ndxHybrid].Get(varName);
609
610 if (!vv && m_enableAdd->GetValue())
611 {
612 vv = vt[ndxHybrid].Create(varName, datatype);
613 Log("Created '" + name + "' in " + m_techList[i] + ", " + m_finList[i] + " (" + GetTypeStr(vv->Type()) + ") = " + vv->AsString());
614 needs_write = true;
615 }
616
617
618 if (!vv)
619 continue;
620
621 if (en_change && vv->Type() != datatype)
622 {
623 needs_write = true;
624 vv->SetType(datatype);
625 Log("Changed data type to " + GetTypeStr(datatype) + " for '" + name + "' in " + m_techList[i] + ", " + m_finList[i]);
626 }

Callers

nothing calls this directly

Calls 15

GetDefaultsFileFunction · 0.85
GetTypeStrFunction · 0.85
resizeMethod · 0.80
sizeMethod · 0.80
lengthMethod · 0.80
TypeMethod · 0.80
AsStringMethod · 0.80
SetTypeMethod · 0.80
ArrayMethod · 0.80
SetObjectMethod · 0.80
GetValueMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected