00001 /* Copyright (C) 2003 Dominic Letourneau (dominic.letourneau@usherbrooke.ca) 00002 00003 This library is free software; you can redistribute it and/or 00004 modify it under the terms of the GNU Lesser General Public 00005 License as published by the Free Software Foundation; either 00006 version 2.1 of the License, or (at your option) any later version. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Lesser General Public License for more details. 00012 00013 You should have received a copy of the GNU Lesser General Public 00014 License along with this library; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00016 */ 00017 #ifndef _EXPLOITATION_H_ 00018 #define _EXPLOITATION_H_ 00019 00020 #include "ExploitationEntry.h" 00021 #include <string> 00022 #include <list> 00023 00024 00025 namespace RobotFlow { 00026 00027 /** 00028 * 00029 * \brief Exploitation contains a list of ExploitationEntr(ies) for Behavior derived classes. 00030 * 00031 * Higher intelligence modules need to know which node have produced an output at a certain iteration count. 00032 * The Exploitation class is responsible of "remembering" which output of a node have been used over a certain period of time. 00033 * 00034 * \author Dominic Létourneau 00035 * \version $Revision: 1.6 $ 00036 * $Date: 2005/03/29 15:20:19 $ 00037 * \par History: 00038 * $Revision: 1.6 $ 00039 * <ul> 00040 * <li>12/05/2003 Added doxygen documentation. 00041 * <li>12/05/2003 Created new file ExploitationEntry.h, class extracted from Exploitation.h 00042 * </ul> 00043 */ 00044 class Exploitation : public FD::Object { 00045 00046 public: 00047 00048 /** 00049 * Constructor with maximum ExploitationEntry in the exploitation registery 00050 * 00051 * \param max_element The maximum ExploitationEntry in the exploitation registery 00052 */ 00053 Exploitation(int max_element = 100); 00054 00055 /** 00056 * Copy Constructor 00057 * 00058 * \param cpy The Exploitation object to copy 00059 */ 00060 Exploitation(const Exploitation& cpy); 00061 00062 /** 00063 * = operator 00064 * 00065 * \param eq The Exploitation object to copy 00066 * \retval Exploitation& self reference 00067 */ 00068 Exploitation &operator =(const Exploitation &eq); 00069 00070 /** 00071 * Destructor 00072 * 00073 */ 00074 virtual ~Exploitation(); 00075 00076 /** 00077 * Printing object to an output stream in the Overflow format. 00078 * 00079 * \param out The output stream to write to. 00080 */ 00081 virtual void printOn(std::ostream &out=std::cout) const; 00082 00083 /** 00084 * Constructor with count, node, output_id args. 00085 * 00086 * \param count The iteration count of the entry 00087 * \param node The node (behavior) where the exploitation occurs 00088 * \param output_id The output_id from the exploited node (behavior) 00089 */ 00090 void add_entry(int count, FD::Node *node, int output_id); 00091 00092 /** 00093 * Sets the maximum number ExploitationEntry in the registery 00094 * 00095 * \param max_element The maximum number of ExploitationEntry in the registery 00096 */ 00097 void set_max_element(int max_element); 00098 00099 /** 00100 * Returns a reference to the list of ExloitationEntry 00101 * 00102 * \retval list<ExploitationEntry>& The reference to the list of ExloitationEntry 00103 */ 00104 std::list<ExploitationEntry> & get_exploitation(){return m_exploitation;} 00105 00106 /** 00107 * Get the maximum number of elements in the ExploitationEntry list 00108 * 00109 * \retval int The maximum number of elements in the ExploitationEntry list 00110 */ 00111 int get_max_element() {return m_max_element;} 00112 00113 /** 00114 * Get the number of ExploitationEntry in the list 00115 * 00116 * \retval int The number of ExploitationEntry in the list 00117 */ 00118 int get_size() {return m_exploitation.size();} 00119 00120 /** 00121 Is the Exploitation object valid ? 00122 \retval bool the isnil flag 00123 */ 00124 virtual bool isNil() const; 00125 00126 void clearNilFlag(); 00127 00128 private: 00129 00130 ///The list of ExploitationEntry (ies) 00131 std::list<ExploitationEntry> m_exploitation; 00132 00133 ///maximum exploitation entries in the list 00134 int m_max_element; 00135 00136 ///the isNil flag 00137 bool m_isNilFlag; 00138 00139 00140 }; 00141 00142 }//namespace RobotFlow 00143 00144 #endif