📄 modulevectorcomponent.hpp
字号:
/* * Open BEAGLE * Copyright (C) 2001-2005 by Christian Gagne and Marc Parizeau * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Contact: * Laboratoire de Vision et Systemes Numeriques * Departement de genie electrique et de genie informatique * Universite Laval, Quebec, Canada, G1K 7P4 * http://vision.gel.ulaval.ca * *//*! * \file beagle/GP/ModuleVectorComponent.hpp * \brief Definition of the class ModuleVectorComponent. * \author Matthew Walker * \author Christian Gagne * $Revision: 1.4 $ * $Date: 2005/09/30 15:04:53 $ */ #ifndef ModuleVectorComponent_hpp#define ModuleVectorComponent_hpp#include "beagle/config.hpp"#include "beagle/macros.hpp"#include "beagle/Object.hpp"#include "beagle/PointerT.hpp"#include "beagle/AllocatorT.hpp"#include "beagle/ContainerT.hpp"#include "beagle/Component.hpp"#include "beagle/RouletteT.hpp"#include "beagle/GP/Tree.hpp"namespace Beagle {namespace GP {/*! * \brief Vector of modules for evolutionary module acquisition. * \ingroup GPF * \ingroup EMA */class ModuleVectorComponent : public Component {public: //! ModuleVectorComponent allocator type. typedef AllocatorT<ModuleVectorComponent,Component::Alloc> Alloc; //! ModuleVectorComponent handle type. typedef PointerT<ModuleVectorComponent,Component::Handle> Handle; //! ModuleVectorComponent bag type. typedef ContainerT<ModuleVectorComponent,Component::Bag> Bag; explicit ModuleVectorComponent(GP::Tree::Alloc::Handle inTreeAlloc=new GP::Tree::Alloc); virtual ~ModuleVectorComponent() { } /*! * \brief Get the nth module. * \param inN Index of the module to get. * \return Reference to the tree handle, that is the nth module. */ inline const GP::Tree::Handle& operator[](unsigned int inN) const { Beagle_StackTraceBeginM(); return mModules[inN]; Beagle_StackTraceEndM("const GP::Tree::Handle& GP::ModuleVectorComponent::operator[](unsigned int inN) const"); } /*! * \brief Get the nth module. * \param inN Index of the module to get. * \return Reference to the tree handle, that is the nth module. */ inline GP::Tree::Handle& operator[](unsigned int inN) { Beagle_StackTraceBeginM(); return mModules[inN]; Beagle_StackTraceEndM("GP::Tree::Handle& GP::ModuleVectorComponent::operator[](unsigned int inN)"); } virtual void readWithSystem(PACC::XML::ConstIterator inIter, Beagle::System& ioSystem); virtual void write(PACC::XML::Streamer& ioStreamer, bool inIndent=true) const; /*! * \brief Add a new GP tree to the vector component. * \param inTree GP tree added. */ inline void add(GP::Tree::Handle inTree) { Beagle_StackTraceBeginM(); mModules.push_back(inTree); Beagle_StackTraceEndM("void GP::ModuleVectorComponent::add(GP::Tree::Handle inTree)"); } /*! * \return True if there is no module acquired, false if not. */ inline bool empty() const { Beagle_StackTraceBeginM(); return mModules.empty(); Beagle_StackTraceEndM("bool GP::ModuleVectorComponent::empty() const"); } /*! * \brief Resize the module vector component. * \param inSize New size of the module vector. */ inline void resize(unsigned int inSize) { Beagle_StackTraceBeginM(); mModules.resize(inSize); Beagle_StackTraceEndM("void GP::ModuleVectorComponent::resize(unsigned int inSize)"); } /*! * \return Number of module in the module vector. */ inline unsigned int size() const { Beagle_StackTraceBeginM(); return mModules.size(); Beagle_StackTraceEndM("unsigned int GP::ModuleVectorComponent::size() const"); }protected: GP::Tree::Bag mModules; //!< Vector of the modules acquired.};}}#endif // ModuleVectorComponent_hpp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -