peoData.h

00001 /*
00002 * <peoData.h>
00003 * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
00004 * (C) OPAC Team, LIFL, 2002-2008
00005 *
00006 * Clive Canape, Thomas Legrand
00007 *
00008 * This software is governed by the CeCILL license under French law and
00009 * abiding by the rules of distribution of free software.  You can  use,
00010 * modify and/ or redistribute the software under the terms of the CeCILL
00011 * license as circulated by CEA, CNRS and INRIA at the following URL
00012 * "http://www.cecill.info".
00013 *
00014 * As a counterpart to the access to the source code and  rights to copy,
00015 * modify and redistribute granted by the license, users are provided only
00016 * with a limited warranty  and the software's author,  the holder of the
00017 * economic rights,  and the successive licensors  have only  limited liability.
00018 *
00019 * In this respect, the user's attention is drawn to the risks associated
00020 * with loading,  using,  modifying and/or developing or reproducing the
00021 * software by the user in light of its specific status of free software,
00022 * that may mean  that it is complicated to manipulate,  and  that  also
00023 * therefore means  that it is reserved for developers  and  experienced
00024 * professionals having in-depth computer knowledge. Users are therefore
00025 * encouraged to load and test the software's suitability as regards their
00026 * requirements in conditions enabling the security of their systems and/or
00027 * peoData to be ensured and,  more generally, to use and operate it in the
00028 * same conditions as regards security.
00029 * The fact that you are presently reading this means that you have had
00030 * knowledge of the CeCILL license and that you accept its terms.
00031 *
00032 * ParadisEO WebSite : http://paradiseo.gforge.inria.fr
00033 * Contact: paradiseo-help@lists.gforge.inria.fr
00034 *
00035 */
00036 
00037 #ifndef _PEODATA_H
00038 #define _PEODATA_H
00039 
00040 #include "core/eoVector_mesg.h"
00041 #include "core/messaging.h"
00042 
00043 /**************************************************************************************/
00044 /**************************  DEFINE A CONTINUATOR   ***********************************/
00045 /**************************************************************************************/
00046 
00051 class continuator
00052   {
00053   public:
00054 
00057     virtual bool check()=0;
00059     virtual ~continuator(){}
00060   };
00061 
00062 
00068 template < class EOT> class eoContinuator : public continuator
00069   {
00070   public:
00071 
00075     eoContinuator(eoContinue<EOT> & _cont, const eoPop<EOT> & _pop): cont (_cont), pop(_pop)
00076     {}
00077 
00080     virtual bool check()
00081     {
00082       return cont(pop);
00083     }
00084 
00085   protected:
00088     eoContinue<EOT> & cont ;
00089     const eoPop<EOT> & pop;
00090   };
00091 
00092 
00093 /**************************************************************************************/
00094 /**************************  DEFINE A SELECTOR   **************************************/
00095 /**************************************************************************************/
00096 
00101 template < class TYPE>  class selector
00102   {
00103   public:
00104 
00107     virtual void operator()(TYPE &)=0;
00109     virtual ~selector(){}
00110   };
00111 
00112 
00118 template < class EOT, class TYPE> class eoSelector : public selector< TYPE >
00119   {
00120   public:
00121 
00126     eoSelector(eoSelectOne<EOT> & _select, unsigned _nb_select, const TYPE & _source): selector (_select), nb_select(_nb_select), source(_source)
00127     {}
00128 
00131     virtual void operator()(TYPE & _dest)
00132     {
00133       size_t target = static_cast<size_t>(nb_select);
00134       _dest.resize(target);
00135       for (size_t i = 0; i < _dest.size(); ++i)
00136         _dest[i] = selector(source);
00137     }
00138 
00139   protected:
00143     eoSelectOne<EOT> & selector ;
00144     unsigned nb_select;
00145     const TYPE & source;
00146   };
00147 
00148 
00149 /**************************************************************************************/
00150 /**************************  DEFINE A REPLACEMENT   ***********************************/
00151 /**************************************************************************************/
00152 
00157 template < class TYPE>  class replacement
00158   {
00159   public:
00162     virtual void operator()(TYPE &)=0;
00164     virtual ~replacement(){}
00165   };
00166 
00167 
00173 template < class EOT, class TYPE> class eoReplace : public replacement< TYPE >
00174   {
00175   public:
00179     eoReplace(eoReplacement<EOT> & _replace, TYPE & _destination): replace(_replace), destination(_destination)
00180     {}
00181 
00184     virtual void operator()(TYPE & _source)
00185     {
00186       replace(destination, _source);
00187     }
00188 
00189   protected:
00192     eoReplacement<EOT> & replace;
00193     TYPE & destination;
00194   };
00195 
00196 
00197 /**************************************************************************************/
00198 /************************  Continuator for synchrone migartion ************************/
00199 /**************************************************************************************/
00200 
00206 class eoSyncContinue: public continuator
00207   {
00208 
00209   public:
00213     eoSyncContinue (unsigned __period, unsigned __init_counter = 0): period (__period),counter (__init_counter)
00214     {}
00215 
00218     virtual bool check()
00219     {
00220       return ((++ counter) % period) != 0 ;
00221     }
00222 
00223 
00224   private:
00227     unsigned period;
00228     unsigned counter;
00229   };
00230 
00231 
00232 #endif
00233 

Generated on Thu Mar 13 15:55:03 2008 for ParadisEO-PEO-ParallelanddistributedEvolvingObjects by  doxygen 1.4.7