Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

rubysceneimporter.h

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
00002 
00003    this file is part of rcssserver3D
00004    Fri May 9 2003
00005    Copyright (C) 2002,2003 Koblenz University
00006    Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
00007    $Id: rubysceneimporter.h,v 1.9 2005/12/18 17:52:32 rollmark Exp $
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; version 2 of the License.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 */
00022 #ifndef RUBYSCENEIMPORTER_H
00023 #define RUBYSCENEIMPORTER_H
00024 
00025 #include <oxygen/sceneserver/sceneimporter.h>
00026 #include <oxygen/sceneserver/basenode.h>
00027 #include <sfsexp/sexp.h>
00028 
00029 class RubySceneImporter : public oxygen::SceneImporter
00030 {
00031 protected:
00033     typedef std::map<std::string, int> TParameterMap;
00034 
00036     struct MethodInvocation
00037     {
00038         boost::weak_ptr<zeitgeist::Node> node;
00039         std::string method;
00040         zeitgeist::ParameterList parameter;
00041     };
00042 
00043     typedef std::list<MethodInvocation> TMethodInvocationList;
00044 
00046     struct ParamEnv
00047     {
00048         TParameterMap parameterMap;
00049         boost::shared_ptr<zeitgeist::ParameterList> parameter;
00050         TMethodInvocationList invocationList;
00051 
00052         ParamEnv();
00053         ParamEnv(boost::shared_ptr<zeitgeist::ParameterList> p)
00054             : parameter(p) {};
00055     };
00056 
00057     typedef std::list<ParamEnv> TParameterStack;
00058 
00059 public:
00060     RubySceneImporter();
00061     virtual ~RubySceneImporter();
00062 
00063     virtual bool ImportScene(const std::string& fileName,
00064                              boost::shared_ptr<oxygen::BaseNode> root,
00065                              boost::shared_ptr<zeitgeist::ParameterList> parameter);
00066 
00067     virtual bool ParseScene(const std::string& scene,
00068                              boost::shared_ptr<oxygen::BaseNode> root,
00069                              boost::shared_ptr<zeitgeist::ParameterList> parameter);
00070 
00076     void SetUnlinkOnCompleteScenes(bool unlink);
00077 
00078 protected:
00079     virtual bool ParseScene(const char* scene, int size,
00080                              boost::shared_ptr<oxygen::BaseNode> root,
00081                              boost::shared_ptr<zeitgeist::ParameterList> parameter);
00082 
00083 
00084     bool ReadHeader(sexp_t* sexp);
00085     bool ReadGraph(sexp_t* sexp, boost::shared_ptr<oxygen::BaseNode> root);
00086     bool ReadDeltaGraph(sexp_t* sexp, boost::shared_ptr<oxygen::BaseNode> root);
00087     boost::shared_ptr<zeitgeist::Object> CreateInstance(const std::string& className);
00088 
00089     void PushInvocation(const MethodInvocation& invoc);
00090     bool Invoke(const MethodInvocation& invoc);
00091     bool InvokeMethods();
00092     bool ReadMethodCall(sexp_t* _sexp, boost::shared_ptr<oxygen::BaseNode> node);
00093 
00094     bool ReplaceVariable(std::string& param);
00095     bool EvalParameter(sexp_t* sexp, std::string& value);
00096 
00097     boost::shared_ptr<oxygen::BaseNode> CreateNode(sexp_t* sexp);
00098     bool ParseTemplate(sexp_t* sexp);
00099     bool ParseDefine(sexp_t* sexp);
00100 
00101     void PushParameter(boost::shared_ptr<zeitgeist::ParameterList> parameter);
00102     void PopParameter();
00103     ParamEnv& GetParamEnv();
00104 
00105 protected:
00108     bool mAutoUnlink;
00109 
00111     bool mDeltaScene;
00112 
00114     float mVersionMajor;
00115 
00117     float mVersionMinor;
00118 
00120     std::string mFileName;
00121 
00123     TParameterStack mParameterStack;
00124 };
00125 
00126 DECLARE_CLASS(RubySceneImporter);
00127 
00128 #endif // RUBYSCENEIMPORTER_H

Generated on Thu Apr 6 15:25:39 2006 for rcssserver3d by  doxygen 1.4.4