00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ScriptingAgent_h
00012 #define ScriptingAgent_h
00013
00014 #include <time.h>
00015 #include <y2/Y2Component.h>
00016 #include <scr/SCRAgent.h>
00017 #include "SCRSubAgent.h"
00018
00022 class ScriptingAgent : public SCRAgent
00023 {
00024
00025 public:
00026
00030 ScriptingAgent ();
00031
00032
00033
00039 ScriptingAgent (const string& file);
00040
00044 ~ScriptingAgent ();
00045
00051 virtual YCPValue Read (const YCPPath &path, const YCPValue &arg = YCPNull (), const YCPValue &opt = YCPNull ());
00052
00056 virtual YCPBoolean Write (const YCPPath &path, const YCPValue &value,
00057 const YCPValue &arg = YCPNull ());
00058
00062 virtual YCPList Dir (const YCPPath &path);
00063
00067 virtual YCPValue Execute (const YCPPath &path, const YCPValue &value =
00068 YCPNull (), const YCPValue &arg = YCPNull ());
00069
00073 virtual YCPMap Error (const YCPPath &path);
00074
00083 YCPValue otherCommand (const YCPTerm &term);
00084
00090 virtual YCPBoolean RegisterAgent (const YCPPath &path, const YCPValue &value);
00091
00095 virtual YCPBoolean UnregisterAgent (const YCPPath &path);
00096
00100 virtual YCPBoolean UnregisterAllAgents ();
00101
00105 virtual YCPBoolean UnmountAgent (const YCPPath &path);
00106
00107 private:
00108
00109
00110
00111
00112 bool done_sweep;
00113
00114
00115 struct RegistrationDir {
00116 string name;
00117 time_t last_changed;
00118 };
00119
00123 list<RegistrationDir> registration_dirs;
00124
00128 void InitRegDirs ();
00129
00134 typedef vector<SCRSubAgent*> SubAgents;
00135 SubAgents agents;
00136
00137
00142 YCPValue MountAgent (const YCPPath &path);
00143
00147 YCPValue MountAllAgents ();
00148
00152 YCPValue UnmountAllAgents ();
00153
00157 void Sweep ();
00158
00168 YCPBoolean RegisterNewAgents ();
00169
00174 void tryRegister (const YCPPath &path);
00175
00180 SubAgents::const_iterator findSubagent (const YCPPath &path);
00181
00187 SubAgents::const_iterator findAndRegisterSubagent (const YCPPath &path);
00188
00192 YCPList dirSubagents (const YCPPath &path);
00193
00204 YCPValue executeSubagentCommand (const char *command,
00205 const YCPPath &path,
00206 const YCPValue &arg = YCPNull (),
00207 const YCPValue &optpar = YCPNull ());
00208
00214 SubAgents::iterator findByPath (const YCPPath &path);
00215
00221 void parseConfigFiles (const string &directory);
00222
00227 void parseSingleConfigFile (const string &file);
00228
00229 };
00230
00231
00232 #endif // ScriptingAgent_h