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
00116 virtual YCPBoolean RegisterNewAgents ();
00117
00118
00119 private:
00120
00121
00122
00123
00124 bool done_sweep;
00125
00126
00127 struct RegistrationDir {
00128 string name;
00129 time_t last_changed;
00130 };
00131
00135 list<RegistrationDir> registration_dirs;
00136
00140 void InitRegDirs ();
00141
00146 typedef vector<SCRSubAgent*> SubAgents;
00147 SubAgents agents;
00148
00149
00154 YCPValue MountAgent (const YCPPath &path);
00155
00159 YCPValue MountAllAgents ();
00160
00164 YCPValue UnmountAllAgents ();
00165
00169 void Sweep ();
00170
00175 void tryRegister (const YCPPath &path);
00176
00181 SubAgents::const_iterator findSubagent (const YCPPath &path);
00182
00188 SubAgents::const_iterator findAndRegisterSubagent (const YCPPath &path);
00189
00193 YCPList dirSubagents (const YCPPath &path);
00194
00205 YCPValue executeSubagentCommand (const char *command,
00206 const YCPPath &path,
00207 const YCPValue &arg = YCPNull (),
00208 const YCPValue &optpar = YCPNull ());
00209
00215 SubAgents::iterator findByPath (const YCPPath &path);
00216
00222 void parseConfigFiles (const string &directory);
00223
00228 void parseSingleConfigFile (const string &file);
00229
00230 };
00231
00232
00233 #endif // ScriptingAgent_h