Simplify configuration.

Remove support for (outdated) <strstream>, require <sstream>.
Require uint32_t for now, defined in stdint.h according to C99.
Some general cleanup and more documentation.
This commit is contained in:
kuepper 2005-09-28 21:49:26 +00:00
commit cf2a57dd88
46 changed files with 482 additions and 886 deletions

View file

@ -4,7 +4,7 @@
// eoHowMany_h.h
// Base class for choosing a number of guys to apply something from a popsize
// (c) Marc Schoenauer, 2000
/*
/*
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
@ -30,11 +30,11 @@
* Typically, is used in selection / replacement procedures, e.g.
* the number of offspring from the number of parents, or
* the number of survivors for an eoReduce functor, ...
*
* Such construct is very useful because in some cases you might not know the
* population size that will enter the replacement. For instance, you
* cannot simply have a pre-computed (double) rate of 1/popSize
* if you want to select or kill just 1 guy. Using an eoHowMany
*
* Such construct is very useful because in some cases you might not know the
* population size that will enter the replacement. For instance, you
* cannot simply have a pre-computed (double) rate of 1/popSize
* if you want to select or kill just 1 guy. Using an eoHowMany
* allows one to modify the population size without touching anything else.
*
* There are 4 possible way to compute the return value from the argument:
@ -49,11 +49,11 @@
* It has 2 private members, a double and an integer to cover all cases
*
* Example use: in <a href="class_eogeneralbreeder.html">eoGeneralBreeder.h</a>
* Example reading from parser: in
* Example reading from parser: in
* <a href="make_algo_scalar_h-source.html">do/make_algo_scalar.h line 141</a>
* MS 10/04/2002:
* Added the possibility to have a negative number -
* MS 10/04/2002:
* Added the possibility to have a negative number -
* when treated as a number: returns then (size - combien)
* Should not modify anything when a positive number is passed in the ctor
*
@ -64,20 +64,12 @@
* It is an eoPersistent because we need to be able to use eoParamValue<eoHowMany>
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_SSTREAM
#include <sstream>
#else
#include <strstream>
#endif
class eoHowMany : public eoPersistent
{
public:
/** Original Ctor from direct rate + bool
/** Original Ctor from direct rate + bool
@param rate the rate, OR the integer to store, depending on 2nd arg.
@param _interpret_as_rate to tell whether the rate actually is a rate
*/
@ -102,18 +94,18 @@ public:
}
}
/** Ctor from an int - both from int and unsigned int are needed
/** Ctor from an int - both from int and unsigned int are needed
* to avoid ambiguity with the Ctor from a double */
eoHowMany(int _combien) : rate(0.0), combien(_combien) {}
/** Ctor from an unsigned int - both from int and unsigned int are needed
/** Ctor from an unsigned int - both from int and unsigned int are needed
* to avoid ambiguity with the Ctor from a double */
eoHowMany(unsigned int _combien) : rate(0.0), combien(_combien) {}
/// Virtual dtor. They are needed in virtual class hierarchies.
virtual ~eoHowMany() {}
/** Does what it was designed for
/** Does what it was designed for
* - combien==0 : return rate*_size
* - else
* - combien>0 : return combien (regardless of _size)
@ -135,7 +127,7 @@ public:
return unsigned(combien);
}
virtual void printOn(std::ostream& _os) const
virtual void printOn(std::ostream& _os) const
{
if (combien == 0)
_os << 100*rate << "% ";
@ -145,7 +137,7 @@ public:
}
virtual void readFrom(std::istream& _is)
virtual void readFrom(std::istream& _is)
{
std::string value;
_is >> value;
@ -163,12 +155,8 @@ public:
interpret_as_rate = true;
_value.resize(pos); // get rid of %
}
#ifdef HAVE_SSTREAM
std::istringstream is(_value);
#else
std::istrstream is(_value.c_str());
#endif
is >> rate;
// now store
if (interpret_as_rate)
@ -193,7 +181,7 @@ public:
combien = -combien;
return (*this);
}
private :
double rate;
int combien;