|
From: <eg...@us...> - 2007-05-17 12:32:29
|
Revision: 472
http://svn.sourceforge.net/opengate/?rev=472&view=rev
Author: egore
Date: 2007-05-17 05:32:30 -0700 (Thu, 17 May 2007)
Log Message:
-----------
[QA] document the vessel manager a bit
[QA] add few todo's
Modified Paths:
--------------
branches/ogsector/src/VesselManager.cpp
branches/ogsector/src/VesselManager.h
Modified: branches/ogsector/src/VesselManager.cpp
===================================================================
--- branches/ogsector/src/VesselManager.cpp 2007-05-17 12:04:38 UTC (rev 471)
+++ branches/ogsector/src/VesselManager.cpp 2007-05-17 12:32:30 UTC (rev 472)
@@ -45,19 +45,19 @@
TiXmlDocument doc( shipResourceFile );
bool loadOkay = doc.LoadFile();
-
+
std::map < int, std::string > ships;
-
+
if ( loadOkay ) {
log_->info( std::string( "open resource file for ships: ") + shipResourceFile );
TiXmlHandle docHandle( &doc );
TiXmlElement* pElem;
TiXmlHandle hRoot( 0 );
-
+
//** block: Ships;
pElem = docHandle.FirstChildElement().Element();
hRoot = TiXmlHandle( pElem );
-
+
if ( pElem ) {
for ( pElem = hRoot.FirstChild( "Resource" ).Element(); pElem != 0; pElem = pElem->NextSiblingElement() ) {
log_->info( std::string( "Found ressource: " ) + pElem->Attribute("location") );
@@ -69,7 +69,7 @@
} else {
// log_->info( shipResourceFile + " cannot open shipResourceFile." );
}
-
+
for ( std::map < int, std::string >::iterator it = ships.begin(); it != ships.end(); it ++ ){
loadAndCreateVessel( it->first, it->second );
}
@@ -82,7 +82,7 @@
bool loadOkay = doc.LoadFile();
if ( loadOkay ) {
-
+
TiXmlHandle docHandle( &doc );
TiXmlElement* pElem;
TiXmlNode* pNode;
@@ -91,12 +91,12 @@
//** block: Ship;
pElem = docHandle.FirstChildElement().Element();
hRoot = TiXmlHandle( pElem );
-
+
if ( !pElem ) {
log_->fatal( fileName + " cannot read first node." );
return NULL;
}
-
+
if ( strcmp( "ship", pElem->Value() ) == 0 ){
Vessel *vessel = new Vessel();
@@ -121,7 +121,7 @@
pElem = hRoot.ChildElement( "techlevel", 0 ).Element();
if ( pElem ) vessel->setTechLevel( toInt( pElem->FirstChild()->Value() ) );
-
+
pElem = hRoot.ChildElement( "size", 0 ).Element();
if ( pElem ) vessel->setBaseSize( toInt( pElem->FirstChild()->Value() ) );
pElem = hRoot.ChildElement( "baseyaw", 0 ).Element();
@@ -151,7 +151,7 @@
pElem = hRoot.ChildElement( "cargocapacity", 0 ).Element();
if ( pElem ) vessel->setCargoSize( toInt( pElem->FirstChild()->Value() ) );
-
+
pElem = hRoot.ChildElement( "capacitorsize", 0 ).Element();
if ( pElem ) vessel->setCapacitorSize( toInt( pElem->FirstChild()->Value() ) );
pElem = hRoot.ChildElement( "powerplantsize", 0 ).Element();
@@ -202,11 +202,9 @@
return NULL;
}
-
-
-VesselManager & VesselManager::getSingleton( ){
- assert( ms_Singleton );
- return ( *ms_Singleton );
+VesselManager & VesselManager::getSingleton( ){
+ assert( ms_Singleton );
+ return ( *ms_Singleton );
}
VesselManager * VesselManager::getSingletonPtr( ){
Modified: branches/ogsector/src/VesselManager.h
===================================================================
--- branches/ogsector/src/VesselManager.h 2007-05-17 12:04:38 UTC (rev 471)
+++ branches/ogsector/src/VesselManager.h 2007-05-17 12:32:30 UTC (rev 472)
@@ -29,8 +29,28 @@
namespace OpenGate{
+/*!
+ * \brief This class defines a vessel.
+ *
+ * A vessel in opengate is that thing, that the user needs to fly around in
+ * space. Others might call it "starship", "spaceshit" or something like that.
+ * A vessel has several properties. It has a weight, a yaw-. a roll- and a
+ * pitch-latency. It also has a drag factor and many properties more. Each
+ * vessel must have these options. The data of a vessel is loaded from an XML
+ * document. This is more or less a logical storage for the vessel, not more and
+ * not less.
+ * \todo Check how to load the XML data into a vessel. My first approach was that
+ * a vessel was passed the name of the XML document and it load everything
+ * from that file. The better approach would be to create something like
+ * an XMLManager, that is able to load a vessel by it's name.
+ * \todo See how to attach objects (capacitory, power plants, weapons) to the
+ * vessel.
+ * \author Carsten <spo...@us...>
+ */
class Vessel{
-public:
+public:
+
+ /*! Constructor creating a dummy vessel */
Vessel(): factionName_( "unknown" ), name_( "unknown" ), className_( "unknown" ){
vesselID_ = 0;
@@ -61,6 +81,7 @@
}
+ /*! Desctructor */
~Vessel(){}
inline void setFactionName( const std::string & name ) { factionName_ = name; }
@@ -151,11 +172,9 @@
pMesh_ = Ogre::MeshManager::getSingleton().load( fileName, "General" );
// pMesh_ = Ogre::MeshManager::getSingleton().load( meshName, "../../trunk/data/ships/octavius/apteryx/" );
}
-
Ogre::MeshPtr & meshPtr( ){ return pMesh_; }
-
-protected:
+protected:
std::string factionName_;
std::string name_;
std::string className_;
@@ -189,19 +208,43 @@
Ogre::MeshPtr pMesh_;
};
+/*!
+ * \brief This singleton class is able to load a vessel by it's name
+ *
+ * The vessel manager is a class to handle access to all vessels. This way a
+ * single entity can handle all vessels and hand them out to whoever requests
+ * access to them. They are loaded once from an XML file and stored internally.
+ * The can be requested by their name or by their unique ID.
+ *
+ * \todo Check if it would make sense to extend an XMLManager that is able to
+ * load every supported type of object in opengate. I guess functionality
+ * between a loader for vessels and for power plants would be really
+ * similar.
+ * \author Carsten <spo...@us...>
+ */
class VesselManager : public Ogre::Singleton< VesselManager >{
public:
+
+ /*! Get the single instance of the VesselManager */
static VesselManager & getSingleton( );
+
+ /*! Get the pointer to single instance of the VesselManager */
static VesselManager * getSingletonPtr( );
+ /*! Constructor */
VesselManager();
+ /*! Destructor that free's all loaded vessels */
~VesselManager();
- void loadVessels( const std::set < std::string > & resourcePaths, const std::string & resourceName );
-
+ /*! This method loads a vessel and stores it in the interal storage
+ * \param resourcePaths An array of all available resource paths
+ * \param resourceName The name of the file to load the vessel from */
+ void loadVessel( const std::set < std::string > & resourcePaths, const std::string & resourceName );
+
Vessel * loadAndCreateVessel( int vesselID, const std::string & filename );
+ /*! This returns a vessel by it's given unique ID \remarks The vessel needs to be loaded before \param vesselID The unique ID of a vessel */
Vessel * vessel( int vesselID ){
if ( vesselID_.count( vesselID ) ){
return vesselID_[ vesselID ];
@@ -211,6 +254,7 @@
}
}
+ /*! This returns a vessel by it's given name \remarks The vessel needs to be loaded before \param vesselID The name of a vessel */
Vessel * vessel( const std::string & vesselName ){
if ( vessels_.count( vesselName ) ){
return vessels_[ vesselName ];
@@ -220,6 +264,7 @@
}
}
+ /*! This returns all vessels for one faction \param factionName The name of the faction */
std::set < Vessel * > factionVessels( const std::string & factionName ){
std::set < Vessel * > vessels;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|