Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

ScriptAgent.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  */
00009 #include "ScriptAgent.h"
00010 
00011 #include "Log.h"
00012 #include "Path.h"
00013 #include "SimpleMsg.h"
00014 #include "IntMsg.h"
00015 #include "StringMsg.h"
00016 #include "MessagerAgent.h"
00017 #include "UnknownMsgException.h"
00018 #include "ScriptException.h"
00019 #include "OptionAgent.h"
00020 #include "ScriptState.h"
00021 
00022 #include "def-script.h"
00023 #include "options-script.h"
00024 
00025 
00026 //-----------------------------------------------------------------
00027     void
00028 ScriptAgent::own_init()
00029 {
00030     m_state = new ScriptState();
00031     m_state->registerFunc("sendMsg", script_options_sendMsg);
00032     m_state->registerFunc("setParam", script_options_setParam);
00033     m_state->registerFunc("getParam", script_options_getParam);
00034 }
00035 //-----------------------------------------------------------------
00036     void
00037 ScriptAgent::own_shutdown()
00038 {
00039     delete m_state;
00040 }
00041 //-----------------------------------------------------------------
00042     void
00043 ScriptAgent::registerFunc(const char *name, lua_CFunction func)
00044 {
00045     m_state->registerFunc(name, func);
00046 }
00047 //-----------------------------------------------------------------
00048 void
00049 ScriptAgent::doFile(const Path &file)
00050 {
00051     m_state->doFile(file);
00052 }
00053 //-----------------------------------------------------------------
00054 /**
00055  * Messages:
00056  * - dostring("input") ... run string
00057  *
00058  * @throws UnknownMsgException
00059  */
00060     void
00061 ScriptAgent::receiveString(const StringMsg *msg)
00062 {
00063     if (msg->equalsName("dostring")) {
00064         m_state->doString(msg->getValue());
00065     }
00066     else {
00067         throw UnknownMsgException(msg);
00068     }
00069 }
00070 
00071 

Generated on Wed Jun 1 09:54:31 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2