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

BaseAgent.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 "BaseAgent.h"
00010 
00011 #include "Log.h"
00012 #include "LogicException.h"
00013 
00014 //-----------------------------------------------------------------
00015 BaseAgent::BaseAgent()
00016 {
00017     m_initialized = false;
00018 }
00019 //-----------------------------------------------------------------
00020     void
00021 BaseAgent::init()
00022 {
00023     LOG_DEBUG(ExInfo("init").addInfo("name", getName()));
00024     //NOTE: agent can call oneself in init()
00025     m_initialized = true;
00026     own_init();
00027 }
00028 //-----------------------------------------------------------------
00029 /**
00030  * @throws LogicException when agent is not initialized.
00031  */
00032     void
00033 BaseAgent::update()
00034 {
00035     if (!m_initialized) {
00036         throw LogicException(ExInfo("agent is not ready")
00037             .addInfo("name", getName()));
00038     }
00039 
00040     own_update();
00041 }
00042 //-----------------------------------------------------------------
00043     void
00044 BaseAgent::shutdown()
00045 {
00046     LOG_DEBUG(ExInfo("shutdown").addInfo("name", getName()));
00047     own_shutdown();
00048     m_initialized = false;
00049 }
00050 

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