[Gcblue-commits] gcb_wx/src/database tcSonobuoyDBObject.cpp,NONE,1.1 tcDatabase.cpp,1.23,1.24
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-03-05 22:38:31
|
Update of /cvsroot/gcblue/gcb_wx/src/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21843/src/database Modified Files: tcDatabase.cpp Added Files: tcSonobuoyDBObject.cpp Log Message: Added sonobuoy model. 2525 view now uses small symbol for ballistic and sonobuoy instead of unknown symbol Index: tcDatabase.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcDatabase.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** tcDatabase.cpp 4 Mar 2005 00:46:16 -0000 1.23 --- tcDatabase.cpp 5 Mar 2005 22:37:51 -0000 1.24 *************** *** 2,6 **** ** @file tcDatabase.cpp */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. ** --- 2,6 ---- ** @file tcDatabase.cpp */ ! /* Copyright (C) 2003-2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** *************** *** 49,52 **** --- 49,53 ---- #include "tcBallisticDBObject.h" #include "tcStoresDBObject.h" + #include "tcSonobuoyDBObject.h" #include "tcTorpedoDBObject.h" #include "tcDatabaseIterator.h" *************** *** 317,320 **** --- 318,329 ---- else serializer.Save(); } + // tcSonobuoyDBObject + { + tcDBObjSerializerSql<tcSonobuoyDBObject> + serializer(this, sqlConnection, "sonobuoys"); + if (load) serializer.Load(); + else serializer.Save(); + } + BuildDictionaries(); } --- NEW FILE: tcSonobuoyDBObject.cpp --- /** ** @file tcSonobuoyDBObject.cpp */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdwx.h" #if _MSC_VER > 1000 #pragma warning(disable:4786) // suppress warning for STL bug in VC6, see Q167355 in the MSDN Library. #endif // _MSC_VER > 1000 #include "tcSonobuoyDBObject.h" #include "common/tinyxml.h" #include "database/tcSqlReader.h" #include <sstream> #ifdef _DEBUG #define new DEBUG_NEW #endif using namespace std; namespace Database { /** * workaround for write serialization issue * @return true if db obj is a leaf obj */ bool tcSonobuoyDBObject::IsLeaf() const { return mnClassID == DTYPE_SONOBUOY; } void tcSonobuoyDBObject::PrintToFile(tcFile& file) { tcDatabaseObject::PrintToFile(file); tcSensorPlatformDBObject::PrintToFile(file); } /** * Loads/saves XML data for database object * @param load true to load, false to save */ void tcSonobuoyDBObject::SerializeXml(TiXmlElement* node, bool load) { if (load) return; // write only for now wxASSERT(node); tcDatabaseObject::SerializeXml(node, load); tcSensorPlatformDBObject::SerializeXml(node, load); TiXmlElement* localNode = node->InsertEndChild(TiXmlElement("sonobuoy"))->ToElement(); localNode->SetAttribute("batteryLife_s", batteryLife_s); localNode->SetAttribute("commRange_km", commRange_km); } /** * Adds sql column definitions to columnString. This is used for * SQL create table command */ void tcSonobuoyDBObject::AddSqlColumns(std::string& columnString) { tcDatabaseObject::AddSqlColumns(columnString); tcSensorPlatformDBObject::AddSqlColumns(columnString); columnString += ","; columnString += "BatteryLife_s number(5),"; columnString += "CommRange_km number(5)"; } void tcSonobuoyDBObject::ReadSql(tcSqlReader& entry) { tcDatabaseObject::ReadSql(entry); tcSensorPlatformDBObject::ReadSql(entry); batteryLife_s = entry.GetDouble("BatteryLife_s"); commRange_km = entry.GetDouble("CommRange_km"); } void tcSonobuoyDBObject::WriteSql(std::string& valueString) { tcDatabaseObject::WriteSql(valueString); tcSensorPlatformDBObject::WriteSql(valueString); std::stringstream s; s << ","; s << batteryLife_s << ","; s << commRange_km; valueString += s.str(); } tcSonobuoyDBObject::tcSonobuoyDBObject() : tcDatabaseObject(), tcSensorPlatformDBObject() { mzClass = "Default Sonobuoy"; mnClassID = DTYPE_SONOBUOY; } tcSonobuoyDBObject::tcSonobuoyDBObject(tcSonobuoyDBObject& obj) : tcDatabaseObject(obj), tcSensorPlatformDBObject(obj), batteryLife_s(obj.batteryLife_s), commRange_km(obj.commRange_km) { mnClassID = DTYPE_SONOBUOY; } tcSonobuoyDBObject::~tcSonobuoyDBObject() { } } |