[Gcblue-commits] gcb_wx/src/common simmath.cpp,1.10,1.11 tcOptions.cpp,1.6,1.7
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-05-08 21:25:35
|
Update of /cvsroot/gcblue/gcb_wx/src/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19946/src/common Modified Files: simmath.cpp tcOptions.cpp Log Message: Index: simmath.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/simmath.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** simmath.cpp 23 Apr 2004 00:15:16 -0000 1.10 --- simmath.cpp 8 May 2004 21:25:25 -0000 1.11 *************** *** 253,256 **** --- 253,269 ---- tcStream& tcTrack::operator>>(tcStream& stream) { + stream << mfLon_rad; + stream << mfLat_rad; + stream << mfAlt_m; + stream << mfSpeed_kts; + stream << mfHeading_rad; + stream << mfClimbAngle_rad; + stream << mfTimestamp; + stream << mnID; + stream << mnPassivePlatformID; + stream << mnClassification; + stream << mnAffiliation; + stream << mnAlliance; + stream << mnFlags; return stream; Index: tcOptions.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/tcOptions.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcOptions.cpp 29 Feb 2004 22:51:35 -0000 1.6 --- tcOptions.cpp 8 May 2004 21:25:26 -0000 1.7 *************** *** 24,28 **** --- 24,37 ---- #include "AError.h" #include <stdio.h> + #include "common/tinyxml.h" + /** + * @return singleton instance + */ + tcOptions* tcOptions::Get() + { + static tcOptions instance; + return &instance; + } /******************************************************************************/ *************** *** 153,156 **** --- 162,219 ---- } + /** + * @return option string value for string option matching optionName + * if option is not found, adds option with value "default" + */ + const char* tcOptions::GetOptionString(const char* optionName) + { + TiXmlNode* node = rootNode->FirstChild(optionName); + if (!node) + { + node = rootNode->InsertEndChild(TiXmlElement(optionName)); + } + + TiXmlNode* child = node->FirstChild(); + if (!child) + { + child = node->InsertEndChild(TiXmlText("default")); + } + + return child->Value(); + } + + /** + * @return true if option string is defined, false otherwise + */ + bool tcOptions::OptionStringExists(const char* optionName) const + { + TiXmlNode* node = rootNode->FirstChild(optionName); + + return (node != 0); + } + + /** + * Updates option string value, creating if necessary + */ + void tcOptions::SetOptionString(const char* optionName, const char* optionValue) + { + TiXmlNode* node = rootNode->FirstChild(optionName); + if (!node) + { + node = rootNode->InsertEndChild(TiXmlElement(optionName)); + } + + TiXmlNode* child = node->FirstChild(); + if (child) + { + child->SetValue(optionValue); + } + else + { + child = node->InsertEndChild(TiXmlText(optionValue)); + } + + } + /******************************************************************************/ void tcOptions::Serialize(int abRead) *************** *** 217,236 **** tcOptions::tcOptions() { ! for(int i=0;i<N_OPTIONS;i++) ! { ! maOptionInfo[i].meType = tsOptionInfo::OT_BOOLEAN; ! maOptionInfo[i].mnStateCount = 0; ! for(int k=0;k<N_OPTION_VALUES;k++) ! { ! maOptionInfo[i].mzCaption[k] = "INVALID"; ! } ! maOptionInfo[i].mnValue = 0; ! maOptionInfo[i].mpAssociated = NULL; ! } ! mnNumOptions = 0; } /******************************************************************************/ tcOptions::~tcOptions() { } --- 280,337 ---- tcOptions::tcOptions() { ! for(int i=0;i<N_OPTIONS;i++) ! { ! maOptionInfo[i].meType = tsOptionInfo::OT_BOOLEAN; ! maOptionInfo[i].mnStateCount = 0; ! for(int k=0;k<N_OPTION_VALUES;k++) ! { ! maOptionInfo[i].mzCaption[k] = "INVALID"; ! } ! maOptionInfo[i].mnValue = 0; ! maOptionInfo[i].mpAssociated = NULL; ! } ! mnNumOptions = 0; ! ! optionsXml = new TiXmlDocument("xml//options.xml"); ! if (!optionsXml->LoadFile()) ! { ! std::cout << "Created empty XML options file " << std::endl; ! optionsXml->SaveFile(); ! } ! optionsXml->LoadFile(); ! rootNode = optionsXml->FirstChild("Options"); ! if (!rootNode) ! { ! rootNode = optionsXml->InsertEndChild(TiXmlElement("Options")); ! } ! ! /* test code ! SetOptionString("testOption", "This is a test option 1 2 3"); ! fprintf(stdout, "TEST STRING: [%s]\n", GetOptionString("testOption")); ! ! SetOptionString("testOption", "This is the modified test option 4 5 6"); ! fprintf(stdout, "TEST STRING2: [%s]\n", GetOptionString("testOption")); ! ! TiXmlNode* node = rootNode->InsertEndChild(TiXmlElement("Test")); ! node->InsertEndChild(TiXmlText("This is some example text")); ! TiXmlNode* testNode = rootNode->FirstChild("Test"); ! TiXmlNode* childNode = testNode->FirstChild(); ! if (childNode) ! { ! fprintf(stdout, "TEST VALUE: [%s]\n", childNode->Value()); ! } ! */ ! Init(); // initializes binary options data } + + /******************************************************************************/ tcOptions::~tcOptions() { + if (optionsXml) + { + optionsXml->SaveFile(); + delete optionsXml; + } } |