From: Markus R. <rol...@us...> - 2005-12-19 20:09:37
|
Update of /cvsroot/simspark/simspark/spark/spark In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5413/spark Added Files: .cvsignore Makefile.am spark.cpp spark.h Log Message: --- NEW FILE: .cvsignore --- .deps .libs Makefile Makefile.in *.la *.lo --- NEW FILE: spark.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2003 Koblenz University $Id: spark.cpp,v 1.1 2005/12/19 20:09:18 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program 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 this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "spark.h" #include <zeitgeist/zeitgeist.h> #include <kerosin/kerosin.h> #include <oxygen/oxygen.h> #include <kerosin/renderserver/rendercontrol.h> #include <kerosin/inputserver/inputcontrol.h> using namespace spark; using namespace kerosin; using namespace oxygen; using namespace zeitgeist; using namespace salt; using namespace std; using namespace boost; Spark::Spark(const string& relPathPrefix) : mZeitgeist(new Zeitgeist("." PACKAGE_NAME, relPathPrefix)), mOxygen(new Oxygen(*mZeitgeist)), mKerosin(new Kerosin(*mZeitgeist)) { } Spark::~Spark() { // reset shared ptr to objects in the zeitgeist hierarchy before // the zeitgeist core is shutdown mLogServer.reset(); mScriptServer.reset(); mSceneServer.reset(); mSimulationServer.reset(); } bool Spark::Init(int argc, char** argv) { mLogServer = mZeitgeist->GetCore()->GetLogServer(); if (mLogServer.get() == 0) { cout << "(Spark) ERROR: LogServer not found\n"; return false; } mScriptServer = mZeitgeist->GetCore()->GetScriptServer(); if (mScriptServer.get() == 0) { mLogServer->Error() << "(Spark) ERROR: ScriptServer not found\n"; return false; } // run the spark init script mZeitgeist->GetCore()->GetRoot()->GetScript()->RunInitScript ( "spark.rb", "lib/spark", ScriptServer::IS_COMMON ); mSceneServer = shared_dynamic_cast<SceneServer> (mZeitgeist->GetCore()->Get("/sys/server/scene")); if (mSceneServer.get() == 0) { mLogServer->Error() << "(Spark) ERROR: SceneServer not found\n"; return false; } mSimulationServer = shared_dynamic_cast<SimulationServer> (mZeitgeist->GetCore()->Get("/sys/server/simulation")); if (mSimulationServer.get() == 0) { mLogServer->Error() << "(Spark) ERROR: SimulationServer not found\n"; return false; } // run the app defined init return InitApp(argc,argv); } bool Spark::InitApp(int /*argc*/, char** /*argv*/) { return true; } Zeitgeist& Spark::GetZeitgeist() { return (*mZeitgeist); } shared_ptr<Core> Spark::GetCore() { return mZeitgeist->GetCore(); } shared_ptr<zeitgeist::LogServer> Spark::GetLog() { return mZeitgeist->GetCore()->GetLogServer(); } shared_ptr<SceneServer> Spark::GetSceneServer() { return mSceneServer; } shared_ptr<SimulationServer> Spark::GetSimulationServer() { return mSimulationServer; } shared_ptr<InputControl> Spark::GetInputControl() { if (mSimulationServer.get() == 0) { return shared_ptr<InputControl>(); } return shared_dynamic_cast<InputControl> (mSimulationServer->GetControlNode("kerosin/InputControl")); } shared_ptr<RenderControl> Spark::GetRenderControl() { if (mSimulationServer.get() == 0) { return shared_ptr<RenderControl>(); } return shared_dynamic_cast<RenderControl> (mSimulationServer->GetControlNode("kerosin/RenderControl")); } shared_ptr<ScriptServer> Spark::GetScriptServer() { return mScriptServer; } shared_ptr<Scene> Spark::GetActiveScene() { shared_ptr<Scene> scene = mSceneServer->GetActiveScene(); if (scene.get() == 0) { mLogServer->Warning() << "(Spark) Warning: no active scene registered\n"; } return scene; } --- NEW FILE: Makefile.am --- if BUILD_KEROSIN if DEBUG pkglib_LTLIBRARIES = libspark_debug.la libspark_debug_la_SOURCES = $(sources) libspark_debug_la_CXXFLAGS = -O -g -W -Wall libspark_debug_la_LIBADD = @FREETYPE_LIBADD@ -lSDL -lIL -lGL libspark_debug_la_LDFLAGS = -version-info @spark_version_info@ else pkglib_LTLIBRARIES = libspark.la libspark_la_SOURCES = $(sources) libspark_la_CXXFLAGS = -O2 libspark_la_LIBADD = @FREETYPE_LIBADD@ -lSDL -lIL -lGL libspark_la_LDFLAGS = -version-info @spark_version_info@ endif endif AM_CPPFLAGS = -I${top_srcdir}/lib -I${top_srcdir}/utility \ @FREETYPE_CPPFLAGS@ @RUBY_CPPFLAGS@ ## define include directory local to the pkgincludedir libpkgincludedir = $(includedir)/@PACKAGE@/spark ## architecture independent data (scripts) to be installed and ## distributed dist_pkgdata_DATA = spark.rb sources = \ spark.cpp nobase_libpkginclude_HEADERS = \ spark.h --- NEW FILE: spark.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2003 Koblenz University $Id: spark.h,v 1.1 2005/12/19 20:09:18 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program 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 this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef SPARK_SPARK_H #define SPARK_SPARK_H #include <string> #include <boost/shared_ptr.hpp> namespace zeitgeist { class Zeitgeist; class LogServer; class ScriptServer; class Core; } namespace oxygen { class Oxygen; class SceneServer; class SimulationServer; class Scene; } namespace kerosin { class Kerosin; class InputControl; class RenderControl; } namespace spark { /** \class Spark is an application framework for apps that use oxygen and kerosin classes. It provides a default setup of and easy access to all relevant classes. Applications that want to use spark should subclass it and override the given callbacks. */ class Spark { public: Spark(const std::string& relPathPrefix); virtual ~Spark(); /** inits the Spark lib, returns true on success, has to be called once before any other spark methods */ bool Init(int argc, char** argv); // // user callbacks /** called once after Spark finished it's init */ virtual bool InitApp(int argc, char** argv); // // set/get methods /** returns the zeitgeist instance */ zeitgeist::Zeitgeist& GetZeitgeist(); /** returns the zeitgeist core instance */ boost::shared_ptr<zeitgeist::Core> GetCore(); /** returns the LogServer */ boost::shared_ptr<zeitgeist::LogServer> GetLog(); /** returns the ScriptServer */ boost::shared_ptr<zeitgeist::ScriptServer> GetScriptServer(); /** returns the SceneServer */ boost::shared_ptr<oxygen::SceneServer> GetSceneServer(); /** returns the current active Scene */ boost::shared_ptr<oxygen::Scene> GetActiveScene(); /** returns the SimulationServer */ boost::shared_ptr<oxygen::SimulationServer> GetSimulationServer(); /** returns the input control node */ boost::shared_ptr<kerosin::InputControl> GetInputControl(); /** returns the render control node */ boost::shared_ptr<kerosin::RenderControl> GetRenderControl(); protected: boost::shared_ptr<zeitgeist::LogServer> mLogServer; boost::shared_ptr<zeitgeist::ScriptServer> mScriptServer; boost::shared_ptr<oxygen::SceneServer> mSceneServer; boost::shared_ptr<oxygen::SimulationServer> mSimulationServer; boost::shared_ptr<zeitgeist::Zeitgeist> mZeitgeist; boost::shared_ptr<oxygen::Oxygen> mOxygen; boost::shared_ptr<kerosin::Kerosin> mKerosin; }; } // namespace kerosin #endif // SPARK_SPARK_H |