Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

Agent.cpp

00001 /*************************************************************************** 00002 * This file is part of OpenCAL: Open Computer Animation Library * 00003 * I created OpenCAL as my master's thesis Computer Science (multimedia) * 00004 * at the tUL university in Diepenbeek, Belgium * 00005 * * 00006 * Copyright (C) 2003-2004 by Jeroen Dierckx * 00007 * jeroen.dierckx@student.luc.ac.be * 00008 * * 00009 ***************************************************************************/ 00010 00011 // Includes 00012 #include "Agent.h" 00013 #include <OpenCAL/System.h> 00014 using namespace OpenCAL; 00015 00016 #include <OpenCAL/NullParentException.h> 00017 using Exceptions::NullParentException; 00018 00019 00020 /****************************** 00021 * Constructors and destructor * 00022 ******************************/ 00023 00024 Agent::Agent(System *parent) 00025 : m_parent(parent), m_initialized(false), m_enabled(true) 00026 { 00027 #ifdef VERBOSE 00028 Debug::print("Agent constructor", 2); 00029 #endif // VERBOSE 00030 00031 if(!parent) 00032 throw NullParentException(__FILE__, __LINE__); 00033 00034 #ifdef VERBOSE 00035 Debug::print("Parent is given, adding to the the parent's agent list...", 2); 00036 #endif // VERBOSE 00037 00038 parent->addAgent(this); 00039 } 00040 00041 Agent::~Agent() 00042 { 00043 #ifdef VERBOSE 00044 Debug::print("Agent destructor", 2); 00045 #endif // VERBOSE 00046 00047 m_parent->deleteAgent(this); 00048 } 00049 00050 00051 /******************** 00052 * General functions * 00053 ********************/ 00054 00055 void Agent::initialize() 00056 { 00057 #ifdef VERBOSE 00058 Debug::print("Agent initialize", 2); 00059 #endif // VERBOSE 00060 00061 m_initialized = true; 00062 } 00063 00064 void Agent::satisfy() 00065 { 00066 #ifdef VERBOSE 00067 Debug::print("Agent satisfy", Debug::maxLevel); 00068 #endif // VERBOSE 00069 00070 if(!isInitialized()) 00071 { 00072 #ifdef VERBOSE 00073 Debug::initWarning("agent"); 00074 #endif // VERBOSE 00075 initialize(); 00076 } 00077 }

Generated on Sun Aug 15 19:19:21 2004 for OpenCAL: Open Computer Animation Library by doxygen 1.3.8