00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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
00052
00053 public:
00054 enum EInitScriptType
00055 {
00056 IS_COMMON,
00057
00058
00059 IS_USERLOCAL
00060
00061
00062 };
00063
00064 protected:
00065 private:
00066
00067
00068
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
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
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 }
00199
00200 #endif //ZEITGEIST_SCRIPTSERVER_H