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

scriptserver.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: scriptserver.h,v 1.20 2004/12/19 14:09:27 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         ScriptServer
00023         :TODO: Class description for ScriptServer
00024 
00025         HISTORY:
00026                 09.07.2002 MK
00027                         - initial version
00028 
00029 */
00030 #ifndef ZEITGEIST_SCRIPTSERVER_H
00031 #define ZEITGEIST_SCRIPTSERVER_H
00032 
00033 #include <zeitgeist/leaf.h>
00034 #include <zeitgeist/class.h>
00035 #include <salt/fileclasses.h>
00036 #include "gcvalue.h"
00037 
00038 namespace zeitgeist
00039 {
00040 
00041 class CoreContext;
00042 
00048 class ScriptServer : public Leaf
00049 {
00050     //
00051     // types
00052     //
00053 public:
00054     enum EInitScriptType
00055         {
00056             IS_COMMON,  // the init script is common for all users,
00057                         // i.e. it won't be copied to the local dot
00058                         // directory
00059             IS_USERLOCAL // the init script is local to the user, i.e
00060                          // it will be copied to the user's dot
00061                          // direcotry
00062         };
00063 
00064 protected:
00065 private:
00066 
00067     //
00068     // functions
00069     //
00070 public:
00072     ScriptServer();
00073     virtual ~ScriptServer();
00074 
00076     bool Run(const std::string &fileName);
00077 
00079     bool Run(boost::shared_ptr<salt::RFile> file);
00080 
00085     void SetInitRelPathPrefix(const std::string &relPathPrefix);
00086 
00093     bool RunInitScript(const std::string &fileName, const std::string &relPath,
00094                        EInitScriptType type = IS_USERLOCAL);
00095 
00097     void SetDotName(const std::string &dotName) { mDotName = dotName; }
00098 
00100     bool Eval(const std::string &command);
00101 
00104     bool Eval(const std::string &command, GCValue& value);
00105 
00106     void UpdateCachedAllNodes();
00107 
00108     // script variable functions
00109 
00111     bool ExistsVariable(const std::string &varName);
00112 
00114     void CreateVariable(const std::string &varName, int value);
00115 
00117     void CreateVariable(const std::string &varName, float value);
00118 
00120     void CreateVariable(const std::string &varName, const std::string &value);
00121 
00123     bool GetVariable(const std::string &varName, int &value);
00124 
00126     bool GetVariable(const std::string &varName, bool &value);
00127 
00129     bool GetVariable(const std::string &varName, std::string &value);
00130 
00132     bool GetVariable(const std::string &varName, float &value);
00133 
00135     boost::shared_ptr<CoreContext> GetContext() const;
00136 
00139     static GCValue GetZeitgeistObject(boost::shared_ptr<Leaf> leaf);
00140 
00141 protected:
00146     virtual bool ConstructInternal();
00147 
00157     bool ParseVarName(const std::string& varName,
00158                       std::string& nameSpace, std::string& name);
00159 
00161     GCValue GetVariable(const std::string &varName);
00162 
00164     bool RunInitScriptInternal(const std::string &dir, const std::string &name,
00165                                bool copy,  const std::string& destDir = "");
00166 
00170     bool GetDotDirName(std::string& dotDir);
00171 
00174     bool CreateDotDir(const std::string& dotDir);
00175 
00176 private:
00177     ScriptServer(const ScriptServer& obj);
00178     ScriptServer& operator=(const ScriptServer& obj);
00179     //
00180     // members
00181     //
00182 public:
00183 protected:
00187     std::string mDotName;
00188 
00191     std::string mRelPathPrefix;
00192 
00193 private:
00194   };
00195 
00196 DECLARE_CLASS(ScriptServer);
00197 
00198 } //namespace zeitgeist
00199 
00200 #endif //ZEITGEIST_SCRIPTSERVER_H

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