Debian Codegraph @

src/gengine/BaseAgent.cpp

raw
1 /*
2 * Copyright (C) 2004 Ivo Danihelka ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9 #include "BaseAgent.h"
10
11 #include "Log.h"
12 #include "LogicException.h"
13
14 //-----------------------------------------------------------------
15 BaseAgent::BaseAgent()
16 {
17 m_initialized = false;
18 }
19 //-----------------------------------------------------------------
20 void
21 BaseAgent::init()
22 {
23 LOG_DEBUG(ExInfo("init").addInfo("name", getName()));
24 //NOTE: agent can call oneself in init()
25 m_initialized = true;
26 own_init();
27 }
28 //-----------------------------------------------------------------
29 /**
30 * @throws LogicException when agent is not initialized.
31 */
32 void
33 BaseAgent::update()
34 {
35 if (!m_initialized) {
36 throw LogicException(ExInfo("agent is not ready")
37 .addInfo("name", getName()));
38 }
39
40 own_update();
41 }
42 //-----------------------------------------------------------------
43 void
44 BaseAgent::shutdown()
45 {
46 LOG_DEBUG(ExInfo("shutdown").addInfo("name", getName()));
47 own_shutdown();
48 m_initialized = false;
49 }
50