Differential Evolution C++ library
C:/dev/de/differentialevolution/listener.hpp
00001 /*
00002  * Copyright (c) 2011 Adrian Michel
00003  * http://www.amichel.com
00004  *
00005  * Permission to use, copy, modify, distribute and sell this 
00006  * software and its documentation for any purpose is hereby 
00007  * granted without fee, provided that both the above copyright 
00008  * notice and this permission notice appear in all copies and in 
00009  * the supporting documentation. 
00010  *  
00011  * This library is distributed in the hope that it will be 
00012  * useful. However, Adrian Michel makes no representations about
00013  * the suitability of this software for any purpose.  It is 
00014  * provided "as is" without any express or implied warranty. 
00015  * 
00016  * Should you find this library useful, please email 
00017  * info@amichel.com with a link or other reference 
00018  * to your work. 
00019 */
00020 
00021 #ifndef DE_LISTENER_HPP_INCLUDED
00022 #define DE_LISTENER_HPP_INCLUDED
00023 
00024 // MS compatible compilers support #pragma once
00025 
00026 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
00027 #pragma once
00028 #endif
00029 
00030 namespace de
00031 {
00032 
00048 class listener
00049 {
00050 public:
00051         virtual ~listener() {}
00052 
00058         virtual void start() = 0;
00067         virtual void end() = 0;
00074         virtual void error() = 0;
00082         virtual void startGeneration( size_t genCount ) = 0;
00093         virtual void endGeneration( size_t genCount, individual_ptr bestIndGen, individual_ptr bestInd ) = 0;
00101         virtual void startSelection( size_t genCount ) = 0;
00109         virtual void endSelection( size_t genCount ) = 0;
00117         virtual void startProcessors( size_t genCount ) = 0;
00126         virtual void endProcessors( size_t genCount ) = 0;
00127 };
00128 
00132 typedef boost::shared_ptr< listener > listener_ptr;
00133 
00139 class null_listener : public listener
00140 {
00141 public:
00142         virtual void start(){}
00143         virtual void end(){}
00144         virtual void error(){}
00145         virtual void startGeneration( size_t genCount ){}
00146         virtual void endGeneration( size_t genCount, individual_ptr bestIndGen, individual_ptr bestInd ){}
00147         virtual void startSelection( size_t genCount ){}
00148         virtual void endSelection( size_t genCount ){}
00149         virtual void startProcessors( size_t genCount ){}
00150         virtual void endProcessors( size_t genCount ){}
00151 };
00152 
00153 }
00154 
00155 #endif //DE_LISTENER_HPP_INCLUDED