Merge branch 'master' of ssh://eodev.git.sourceforge.net/gitroot/eodev/eodev
This commit is contained in:
commit
4703121227
13 changed files with 199 additions and 294 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
mkdir release
|
mkdir -p release
|
||||||
cd release
|
cd release
|
||||||
cmake -DENABLE_EO_TUTORIAL=1 ..
|
cmake -DENABLE_EO_TUTORIAL=1 ..
|
||||||
make
|
make
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||||
mak@dhi.dk
|
mak@dhi.dk
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -94,7 +94,7 @@ void omp_apply(eoUF<EOT&, void>& _proc, std::vector<EOT>& _pop)
|
||||||
//default(none) shared(_proc, _pop, size)
|
//default(none) shared(_proc, _pop, size)
|
||||||
for (size_t i = 0; i < size; ++i)
|
for (size_t i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
_proc(_pop[i]);
|
_proc(_pop[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,7 +112,7 @@ void omp_dynamic_apply(eoUF<EOT&, void>& _proc, std::vector<EOT>& _pop)
|
||||||
//default(none) shared(_proc, _pop, size)
|
//default(none) shared(_proc, _pop, size)
|
||||||
for (size_t i = 0; i < size; ++i)
|
for (size_t i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
_proc(_pop[i]);
|
_proc(_pop[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -199,8 +199,7 @@
|
||||||
#include <eoLinearDecreasingWeightUp.h>
|
#include <eoLinearDecreasingWeightUp.h>
|
||||||
#include <eoGaussRealWeightUp.h>
|
#include <eoGaussRealWeightUp.h>
|
||||||
|
|
||||||
#include <utils/eoParserLogger.h>
|
#include <utils/eoLogger.h>
|
||||||
|
|
||||||
#include <utils/eoParallel.h>
|
#include <utils/eoParallel.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -14,25 +14,28 @@ SET(CMA_LIB_OUTPUT_PATH ${EO_BINARY_DIR}/lib)
|
||||||
|
|
||||||
SET(LIBRARY_OUTPUT_PATH ${ES_LIB_OUTPUT_PATH}) # the same output for the two libs
|
SET(LIBRARY_OUTPUT_PATH ${ES_LIB_OUTPUT_PATH}) # the same output for the two libs
|
||||||
|
|
||||||
SET (ES_SOURCES make_algo_scalar_es.cpp
|
SET(ES_SOURCES
|
||||||
make_algo_scalar_real.cpp
|
make_algo_scalar_es.cpp
|
||||||
make_checkpoint_es.cpp
|
make_algo_scalar_real.cpp
|
||||||
make_checkpoint_real.cpp
|
make_checkpoint_es.cpp
|
||||||
make_continue_es.cpp
|
make_checkpoint_real.cpp
|
||||||
make_continue_real.cpp
|
make_continue_es.cpp
|
||||||
make_genotype_es.cpp
|
make_continue_real.cpp
|
||||||
make_genotype_real.cpp
|
make_genotype_es.cpp
|
||||||
make_op_es.cpp
|
make_genotype_real.cpp
|
||||||
make_op_real.cpp
|
make_op_es.cpp
|
||||||
make_pop_es.cpp
|
make_op_real.cpp
|
||||||
make_pop_real.cpp
|
make_pop_es.cpp
|
||||||
make_run_es.cpp
|
make_pop_real.cpp
|
||||||
make_run_real.cpp)
|
make_run_es.cpp
|
||||||
|
make_run_real.cpp
|
||||||
SET (CMA_SOURCES eig.cpp
|
)
|
||||||
CMAState.cpp
|
|
||||||
CMAParams.cpp)
|
|
||||||
|
|
||||||
|
SET(CMA_SOURCES
|
||||||
|
eig.cpp
|
||||||
|
CMAState.cpp
|
||||||
|
CMAParams.cpp
|
||||||
|
)
|
||||||
|
|
||||||
ADD_LIBRARY(es STATIC ${ES_SOURCES})
|
ADD_LIBRARY(es STATIC ${ES_SOURCES})
|
||||||
INSTALL(TARGETS es ARCHIVE DESTINATION lib COMPONENT libraries)
|
INSTALL(TARGETS es ARCHIVE DESTINATION lib COMPONENT libraries)
|
||||||
|
|
@ -54,4 +57,3 @@ SET(CMA_VERSION ${GLOBAL_VERSION})
|
||||||
SET_TARGET_PROPERTIES(cma PROPERTIES VERSION "${CMA_VERSION}")
|
SET_TARGET_PROPERTIES(cma PROPERTIES VERSION "${CMA_VERSION}")
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,15 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
SET(GA_LIB_OUTPUT_PATH ${EO_BINARY_DIR}/lib)
|
SET(GA_LIB_OUTPUT_PATH ${EO_BINARY_DIR}/lib)
|
||||||
SET(LIBRARY_OUTPUT_PATH ${GA_LIB_OUTPUT_PATH})
|
SET(LIBRARY_OUTPUT_PATH ${GA_LIB_OUTPUT_PATH})
|
||||||
|
|
||||||
SET (GA_SOURCES make_algo_scalar_ga.cpp
|
SET(GA_SOURCES
|
||||||
make_checkpoint_ga.cpp
|
make_algo_scalar_ga.cpp
|
||||||
make_continue_ga.cpp
|
make_checkpoint_ga.cpp
|
||||||
make_genotype_ga.cpp
|
make_continue_ga.cpp
|
||||||
make_op_ga.cpp
|
make_genotype_ga.cpp
|
||||||
make_pop_ga.cpp
|
make_op_ga.cpp
|
||||||
make_run_ga.cpp)
|
make_pop_ga.cpp
|
||||||
|
make_run_ga.cpp
|
||||||
|
)
|
||||||
|
|
||||||
ADD_LIBRARY(ga STATIC ${GA_SOURCES})
|
ADD_LIBRARY(ga STATIC ${GA_SOURCES})
|
||||||
INSTALL(TARGETS ga ARCHIVE DESTINATION lib COMPONENT libraries)
|
INSTALL(TARGETS ga ARCHIVE DESTINATION lib COMPONENT libraries)
|
||||||
|
|
@ -35,4 +36,3 @@ SET(GA_VERSION ${GLOBAL_VERSION})
|
||||||
SET_TARGET_PROPERTIES(ga PROPERTIES VERSION "${GA_VERSION}")
|
SET_TARGET_PROPERTIES(ga PROPERTIES VERSION "${GA_VERSION}")
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,2 @@
|
||||||
FILE(GLOB HDRS *.h)
|
FILE(GLOB HDRS *.h)
|
||||||
INSTALL(FILES ${HDRS} DESTINATION include/eo/gp COMPONENT headers)
|
INSTALL(FILES ${HDRS} DESTINATION include/eo/gp COMPONENT headers)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,24 +12,24 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
SET(EOUTILS_LIB_OUTPUT_PATH ${EO_BINARY_DIR}/lib)
|
SET(EOUTILS_LIB_OUTPUT_PATH ${EO_BINARY_DIR}/lib)
|
||||||
SET(LIBRARY_OUTPUT_PATH ${EOUTILS_LIB_OUTPUT_PATH})
|
SET(LIBRARY_OUTPUT_PATH ${EOUTILS_LIB_OUTPUT_PATH})
|
||||||
|
|
||||||
SET (EOUTILS_SOURCES eoData.cpp
|
SET(EOUTILS_SOURCES
|
||||||
eoFileMonitor.cpp
|
eoData.cpp
|
||||||
eoGnuplot.cpp
|
eoFileMonitor.cpp
|
||||||
eoGnuplot1DMonitor.cpp
|
eoGnuplot.cpp
|
||||||
eoGnuplot1DSnapshot.cpp
|
eoGnuplot1DMonitor.cpp
|
||||||
eoIntBounds.cpp
|
eoGnuplot1DSnapshot.cpp
|
||||||
eoParser.cpp
|
eoIntBounds.cpp
|
||||||
eoRealBounds.cpp
|
eoParser.cpp
|
||||||
eoRNG.cpp
|
eoRealBounds.cpp
|
||||||
eoState.cpp
|
eoRNG.cpp
|
||||||
eoOStreamMonitor.cpp
|
eoState.cpp
|
||||||
eoUpdater.cpp
|
eoOStreamMonitor.cpp
|
||||||
make_help.cpp
|
eoUpdater.cpp
|
||||||
pipecom.cpp
|
make_help.cpp
|
||||||
eoLogger.cpp
|
pipecom.cpp
|
||||||
eoParserLogger.cpp
|
eoLogger.cpp
|
||||||
eoParallel.cpp)
|
eoParallel.cpp
|
||||||
|
)
|
||||||
|
|
||||||
ADD_LIBRARY(eoutils STATIC ${EOUTILS_SOURCES})
|
ADD_LIBRARY(eoutils STATIC ${EOUTILS_SOURCES})
|
||||||
INSTALL(TARGETS eoutils ARCHIVE DESTINATION lib COMPONENT libraries)
|
INSTALL(TARGETS eoutils ARCHIVE DESTINATION lib COMPONENT libraries)
|
||||||
|
|
|
||||||
|
|
@ -26,30 +26,31 @@ Authors:
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef _INTERIX
|
#ifdef _WIN32
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#else // _INTERIX
|
#else // _WIN32
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif // ! _INTERIX
|
#endif // ! _WIN32
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdio> // used to define EOF
|
#include <cstdio> // used to define EOF
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
|
||||||
#include <exception>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <locale>
|
|
||||||
|
|
||||||
#include "eoLogger.h"
|
#include "eoLogger.h"
|
||||||
|
|
||||||
eoLogger eo::log;
|
eoLogger::eoLogger() :
|
||||||
|
std::ostream(&_obuf),
|
||||||
|
|
||||||
eoLogger::eoLogger()
|
_verbose("quiet", "verbose", "Set the verbose level", 'v'),
|
||||||
: std::ostream(&_obuf),
|
_printVerboseLevels(false, "print-verbose-levels", "Print verbose levels", 'l'),
|
||||||
_selectedLevel(eo::progress), _contextLevel(eo::quiet),
|
_output("", "output", "Redirect a standard output to a file", 'o'),
|
||||||
_fd(2), _obuf(_fd, _contextLevel, _selectedLevel)
|
|
||||||
|
_selectedLevel(eo::progress),
|
||||||
|
_contextLevel(eo::quiet),
|
||||||
|
_fd(2),
|
||||||
|
_obuf(_fd, _contextLevel, _selectedLevel)
|
||||||
{
|
{
|
||||||
_standard_io_streams[&std::cout] = 1;
|
_standard_io_streams[&std::cout] = 1;
|
||||||
_standard_io_streams[&std::clog] = 2;
|
_standard_io_streams[&std::clog] = 2;
|
||||||
|
|
@ -71,18 +72,56 @@ eoLogger::~eoLogger()
|
||||||
if (_fd > 2) { ::close(_fd); }
|
if (_fd > 2) { ::close(_fd); }
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string eoLogger::className() const
|
void eoLogger::_createParameters( eoParser& parser )
|
||||||
|
{
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// we are saying to eoParser to create the parameters created above.
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
std::string section("Logger");
|
||||||
|
parser.processParam(_verbose, section);
|
||||||
|
parser.processParam(_printVerboseLevels, section);
|
||||||
|
parser.processParam(_output, section);
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// we're gonna redirect the log to the given filename if -o is used.
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ( ! _output.value().empty() )
|
||||||
|
{
|
||||||
|
eo::log << eo::file( _output.value() );
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// // we're gonna print the list of levels if -l parameter is used.
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ( _printVerboseLevels.value() )
|
||||||
|
{
|
||||||
|
eo::log.printLevels();
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string eoLogger::className() const
|
||||||
{
|
{
|
||||||
return ("eoLogger");
|
return ("eoLogger");
|
||||||
}
|
}
|
||||||
|
|
||||||
void eoLogger::addLevel(std::string name, eo::Levels level)
|
void eoLogger::addLevel(std::string name, eo::Levels level)
|
||||||
{
|
{
|
||||||
_levels[name] = level;
|
_levels[name] = level;
|
||||||
_sortedLevels.push_back(name);
|
_sortedLevels.push_back(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void eoLogger::printLevels() const
|
void eoLogger::printLevels() const
|
||||||
{
|
{
|
||||||
std::cout << "Available verbose levels:" << std::endl;
|
std::cout << "Available verbose levels:" << std::endl;
|
||||||
|
|
||||||
|
|
@ -95,25 +134,25 @@ void eoLogger::printLevels() const
|
||||||
::exit(0);
|
::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
eoLogger& operator<<(eoLogger& l, const eo::Levels lvl)
|
eoLogger& operator<<(eoLogger& l, const eo::Levels lvl)
|
||||||
{
|
{
|
||||||
l._contextLevel = lvl;
|
l._contextLevel = lvl;
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
eoLogger& operator<<(eoLogger& l, eo::file f)
|
eoLogger& operator<<(eoLogger& l, eo::file f)
|
||||||
{
|
{
|
||||||
l._fd = ::open(f._f.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
|
l._fd = ::open(f._f.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
eoLogger& operator<<(eoLogger& l, eo::setlevel v)
|
eoLogger& operator<<(eoLogger& l, eo::setlevel v)
|
||||||
{
|
{
|
||||||
l._selectedLevel = (v._lvl < 0 ? l._levels[v._v] : v._lvl);
|
l._selectedLevel = (v._lvl < 0 ? l._levels[v._v] : v._lvl);
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
eoLogger& operator<<(eoLogger& l, std::ostream& os)
|
eoLogger& operator<<(eoLogger& l, std::ostream& os)
|
||||||
{
|
{
|
||||||
if (l._standard_io_streams.find(&os) != l._standard_io_streams.end())
|
if (l._standard_io_streams.find(&os) != l._standard_io_streams.end())
|
||||||
{
|
{
|
||||||
|
|
@ -128,20 +167,20 @@ eoLogger::outbuf::outbuf(const int& fd,
|
||||||
: _fd(fd), _contextLevel(contexlvl), _selectedLevel(selectedlvl)
|
: _fd(fd), _contextLevel(contexlvl), _selectedLevel(selectedlvl)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
int eoLogger::outbuf::overflow(int_type c)
|
int eoLogger::outbuf::overflow(int_type c)
|
||||||
{
|
{
|
||||||
if (_selectedLevel >= _contextLevel)
|
if (_selectedLevel >= _contextLevel)
|
||||||
{
|
{
|
||||||
if (_fd >= 0 && c != EOF)
|
if (_fd >= 0 && c != EOF)
|
||||||
{
|
{
|
||||||
ssize_t num;
|
size_t num;
|
||||||
num = ::write(_fd, &c, 1);
|
num = ::write(_fd, &c, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace eo
|
namespace eo
|
||||||
{
|
{
|
||||||
file::file(const std::string f)
|
file::file(const std::string f)
|
||||||
: _f(f)
|
: _f(f)
|
||||||
|
|
@ -155,3 +194,13 @@ namespace eo
|
||||||
: _v(std::string("")), _lvl(lvl)
|
: _v(std::string("")), _lvl(lvl)
|
||||||
{}
|
{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! make_verbose gets level of verbose and sets it in eoLogger
|
||||||
|
void make_verbose(eoParser& parser)
|
||||||
|
{
|
||||||
|
eo::log._createParameters( parser );
|
||||||
|
|
||||||
|
eo::log << eo::setlevel(eo::log._verbose.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
eoLogger eo::log;
|
||||||
|
|
|
||||||
|
|
@ -32,15 +32,12 @@ Caner Candan <caner.candan@thalesgroup.com>
|
||||||
|
|
||||||
Here's an example explaning how to use eoLogger:
|
Here's an example explaning how to use eoLogger:
|
||||||
\code
|
\code
|
||||||
#include <iostream>
|
#include <eo>
|
||||||
#include <utils/eoLogger.h>
|
|
||||||
#include <utils/eoParserLogger.h>
|
|
||||||
|
|
||||||
int main(int ac, char** av)
|
int main(int ac, char** av)
|
||||||
{
|
{
|
||||||
// We are declaring first an overload of eoParser class using Logger
|
// We are declaring the usual eoParser class
|
||||||
// component.
|
eoParser parser(ac, av);
|
||||||
eoParserLogger parser(ac, av);
|
|
||||||
|
|
||||||
// This call is important to allow -v parameter to change user level.
|
// This call is important to allow -v parameter to change user level.
|
||||||
make_verbose(parser);
|
make_verbose(parser);
|
||||||
|
|
@ -88,17 +85,17 @@ Caner Candan <caner.candan@thalesgroup.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef eoLogger_h
|
#ifndef eoLogger_h
|
||||||
# define eoLogger_h
|
#define eoLogger_h
|
||||||
|
|
||||||
# include <map>
|
#include <map>
|
||||||
# include <vector>
|
#include <vector>
|
||||||
# include <string>
|
#include <string>
|
||||||
# include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
# include "eoObject.h"
|
#include "eoObject.h"
|
||||||
|
#include "eoParser.h"
|
||||||
|
|
||||||
|
namespace eo
|
||||||
namespace eo
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Levels contents all the available levels in eoLogger
|
* Levels contents all the available levels in eoLogger
|
||||||
|
|
@ -117,7 +114,7 @@ namespace eo
|
||||||
* file
|
* file
|
||||||
* this structure combined with the friend operator<< below is an easy way to select a file as output.
|
* this structure combined with the friend operator<< below is an easy way to select a file as output.
|
||||||
*/
|
*/
|
||||||
struct file
|
struct file
|
||||||
{
|
{
|
||||||
file(const std::string f);
|
file(const std::string f);
|
||||||
const std::string _f;
|
const std::string _f;
|
||||||
|
|
@ -127,7 +124,7 @@ namespace eo
|
||||||
* setlevel
|
* setlevel
|
||||||
* this structure combined with the friend operator<< below is an easy way to set a verbose level.
|
* this structure combined with the friend operator<< below is an easy way to set a verbose level.
|
||||||
*/
|
*/
|
||||||
struct setlevel
|
struct setlevel
|
||||||
{
|
{
|
||||||
setlevel(const std::string v);
|
setlevel(const std::string v);
|
||||||
setlevel(const Levels lvl);
|
setlevel(const Levels lvl);
|
||||||
|
|
@ -141,14 +138,14 @@ namespace eo
|
||||||
* Class providing a verbose management through EO
|
* Class providing a verbose management through EO
|
||||||
* Use of a global variable eo::log to easily use the logger like std::cout
|
* Use of a global variable eo::log to easily use the logger like std::cout
|
||||||
*/
|
*/
|
||||||
class eoLogger : public eoObject,
|
class eoLogger : public eoObject,
|
||||||
public std::ostream
|
public std::ostream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
eoLogger();
|
eoLogger();
|
||||||
~eoLogger();
|
~eoLogger();
|
||||||
|
|
||||||
virtual std::string className() const;
|
virtual std::string className() const;
|
||||||
|
|
||||||
//! Print the available levels on the standard output
|
//! Print the available levels on the standard output
|
||||||
void printLevels() const;
|
void printLevels() const;
|
||||||
|
|
@ -158,107 +155,115 @@ public:
|
||||||
* Use this function if you want to be able to compare selected levels to a given one, like:
|
* Use this function if you want to be able to compare selected levels to a given one, like:
|
||||||
* if( eo::log.getLevelSelected() >= eo::progress ) {...}
|
* if( eo::log.getLevelSelected() >= eo::progress ) {...}
|
||||||
*/
|
*/
|
||||||
eo::Levels getLevelSelected() const { return _selectedLevel; }
|
inline eo::Levels getLevelSelected() const { return _selectedLevel; }
|
||||||
|
|
||||||
/*! Returns the current level of the context
|
/*! Returns the current level of the context
|
||||||
* the one given when you output message with the logger
|
* the one given when you output message with the logger
|
||||||
*/
|
*/
|
||||||
eo::Levels getLevelContext() const { return _contextLevel; }
|
inline eo::Levels getLevelContext() const { return _contextLevel; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void addLevel(std::string name, eo::Levels level);
|
void addLevel(std::string name, eo::Levels level);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void _createParameters( eoParser& );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* outbuf
|
* outbuf
|
||||||
* this class inherits from std::streambuf which is used by eoLogger to write the buffer in an output stream
|
* this class inherits from std::streambuf which is used by eoLogger to write the buffer in an output stream
|
||||||
*/
|
*/
|
||||||
class outbuf : public std::streambuf
|
class outbuf : public std::streambuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
outbuf(const int& fd,
|
outbuf(const int& fd, const eo::Levels& contexlvl, const eo::Levels& selectedlvl);
|
||||||
const eo::Levels& contexlvl,
|
|
||||||
const eo::Levels& selectedlvl);
|
|
||||||
protected:
|
protected:
|
||||||
virtual int overflow(int_type c);
|
virtual int overflow(int_type c);
|
||||||
private:
|
private:
|
||||||
const int& _fd;
|
const int& _fd;
|
||||||
const eo::Levels& _contextLevel;
|
const eo::Levels& _contextLevel;
|
||||||
const eo::Levels& _selectedLevel;
|
const eo::Levels& _selectedLevel;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* MapLevel is the type used by the map member _levels.
|
* MapLevel is the type used by the map member _levels.
|
||||||
*/
|
*/
|
||||||
typedef std::map<std::string, eo::Levels> MapLevel;
|
typedef std::map<std::string, eo::Levels> MapLevel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* operator<< used there to set a verbose mode.
|
* operator<< used there to set a verbose mode.
|
||||||
*/
|
*/
|
||||||
friend eoLogger& operator<<(eoLogger&, const eo::Levels);
|
friend eoLogger& operator<<(eoLogger&, const eo::Levels);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* operator<< used there to set a filename through the class file.
|
* operator<< used there to set a filename through the class file.
|
||||||
*/
|
*/
|
||||||
friend eoLogger& operator<<(eoLogger&, eo::file);
|
friend eoLogger& operator<<(eoLogger&, eo::file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* operator<< used there to set a verbose level through the class setlevel.
|
* operator<< used there to set a verbose level through the class setlevel.
|
||||||
*/
|
*/
|
||||||
friend eoLogger& operator<<(eoLogger&, eo::setlevel);
|
friend eoLogger& operator<<(eoLogger&, eo::setlevel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* operator<< used there to be able to use std::cout to say that we wish to redirect back the buffer to a standard output.
|
* operator<< used there to be able to use std::cout to say that we wish to redirect back the buffer to a standard output.
|
||||||
*/
|
*/
|
||||||
friend eoLogger& operator<<(eoLogger&, std::ostream&);
|
friend eoLogger& operator<<(eoLogger&, std::ostream&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend void make_verbose(eoParser&);
|
||||||
|
|
||||||
|
eoValueParam<std::string> _verbose;
|
||||||
|
eoValueParam<bool> _printVerboseLevels;
|
||||||
|
eoValueParam<std::string> _output;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _selectedLevel is the member storing verbose level setted by the user thanks to operator()
|
* _selectedLevel is the member storing verbose level setted by the user thanks to operator()
|
||||||
*/
|
*/
|
||||||
eo::Levels _selectedLevel;
|
eo::Levels _selectedLevel;
|
||||||
eo::Levels _contextLevel;
|
eo::Levels _contextLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _fd in storing the file descriptor at this place we can disable easily the buffer in
|
* _fd in storing the file descriptor at this place we can disable easily the buffer in
|
||||||
* changing the value at -1. It is used by operator <<.
|
* changing the value at -1. It is used by operator <<.
|
||||||
*/
|
*/
|
||||||
int _fd;
|
int _fd;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _obuf std::ostream mandates to use a buffer. _obuf is a outbuf inheriting of std::streambuf.
|
* _obuf std::ostream mandates to use a buffer. _obuf is a outbuf inheriting of std::streambuf.
|
||||||
*/
|
*/
|
||||||
outbuf _obuf;
|
outbuf _obuf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _levels contains all the existing level order by position
|
* _levels contains all the existing level order by position
|
||||||
*/
|
*/
|
||||||
MapLevel _levels;
|
MapLevel _levels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _levelsOrder is just a list to keep the order of levels
|
* _levelsOrder is just a list to keep the order of levels
|
||||||
*/
|
*/
|
||||||
std::vector<std::string> _sortedLevels;
|
std::vector<std::string> _sortedLevels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _standard_io_streams
|
* _standard_io_streams
|
||||||
*/
|
*/
|
||||||
std::map< std::ostream*, int > _standard_io_streams;
|
std::map< std::ostream*, int > _standard_io_streams;
|
||||||
};
|
};
|
||||||
/** @example t-eoLogger.cpp
|
/** @example t-eoLogger.cpp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace eo
|
void make_verbose(eoParser&);
|
||||||
|
|
||||||
|
namespace eo
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* log is an external global variable defined to easily use a same way than std::cout to write a log.
|
* log is an external global variable defined to easily use a same way than std::cout to write a log.
|
||||||
*/
|
*/
|
||||||
extern eoLogger log;
|
extern eoLogger log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#endif // !eoLogger_h
|
#endif // !eoLogger_h
|
||||||
|
|
|
||||||
|
|
@ -1,80 +0,0 @@
|
||||||
/*
|
|
||||||
|
|
||||||
(c) Thales group, 2010
|
|
||||||
|
|
||||||
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; version 2 of the license.
|
|
||||||
|
|
||||||
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: http://eodev.sourceforge.net
|
|
||||||
|
|
||||||
Authors:
|
|
||||||
Johann Dreo <johann.dreo@thalesgroup.com>
|
|
||||||
Caner Candan <caner.candan@thalesgroup.com>
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "eoParserLogger.h"
|
|
||||||
|
|
||||||
eoParserLogger::eoParserLogger(unsigned _argc, char** _argv,
|
|
||||||
std::string _programDescription /*= ""*/
|
|
||||||
,
|
|
||||||
std::string _lFileParamName /*= "param-file"*/,
|
|
||||||
char _shortHand /*= 'p'*/)
|
|
||||||
: eoParser(_argc, _argv, _programDescription, _lFileParamName, _shortHand),
|
|
||||||
_verbose("quiet", "verbose", "Set the verbose level", 'v'),
|
|
||||||
_printVerboseLevels(false, "print-verbose-levels", "Print verbose levels", 'l'),
|
|
||||||
_output("", "output", "Redirect a standard output to a file", 'o')
|
|
||||||
{
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
// we are saying to eoParser to create the parameters created above.
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
|
|
||||||
processParam(_verbose);
|
|
||||||
processParam(_printVerboseLevels);
|
|
||||||
processParam(_output);
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
// we're gonna redirect the log to the given filename if -o is used.
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
|
|
||||||
if ( ! _output.value().empty() )
|
|
||||||
{
|
|
||||||
eo::log << eo::file( _output.value() );
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
// // we're gonna print the list of levels if -l parameter is used.
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
|
|
||||||
if ( _printVerboseLevels.value() )
|
|
||||||
{
|
|
||||||
eo::log.printLevels();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
eoParserLogger::~eoParserLogger()
|
|
||||||
{}
|
|
||||||
|
|
||||||
//! make_verbose gets level of verbose and sets it in eoLogger
|
|
||||||
void make_verbose(eoParserLogger& _parser)
|
|
||||||
{
|
|
||||||
eo::log << eo::setlevel(_parser._verbose.value());
|
|
||||||
}
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
|
|
||||||
(c) Thales group, 2010
|
|
||||||
|
|
||||||
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; version 2 of the license.
|
|
||||||
|
|
||||||
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: http://eodev.sourceforge.net
|
|
||||||
|
|
||||||
Authors:
|
|
||||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
|
||||||
Caner Candan <caner.candan@thalesgroup.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef EO_PARSER_LOGGER_H
|
|
||||||
#define EO_PARSER_LOGGER_H
|
|
||||||
|
|
||||||
#include "eoParser.h"
|
|
||||||
#include "eoLogger.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A parser that use the advanced logging system (@see eoLogger)
|
|
||||||
*
|
|
||||||
* @ingroup Parameters
|
|
||||||
* @ingroup Logging
|
|
||||||
*/
|
|
||||||
class eoParserLogger : public eoParser
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
eoParserLogger(unsigned _argc, char** _argv,
|
|
||||||
std::string _programDescription = "",
|
|
||||||
std::string _lFileParamName = "param-file",
|
|
||||||
char _shortHand = 'p');
|
|
||||||
~eoParserLogger();
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend void make_verbose(eoParserLogger&);
|
|
||||||
eoValueParam<std::string> _verbose;
|
|
||||||
eoValueParam<bool> _printVerboseLevels;
|
|
||||||
eoValueParam<std::string> _output;
|
|
||||||
};
|
|
||||||
|
|
||||||
void make_verbose(eoParserLogger&);
|
|
||||||
|
|
||||||
#endif // !EO_PARSER_LOGGER_H
|
|
||||||
|
|
||||||
// Local Variables:
|
|
||||||
// coding: iso-8859-1
|
|
||||||
// mode: C++
|
|
||||||
// c-file-offsets: ((c . 0))
|
|
||||||
// c-file-style: "Stroustrup"
|
|
||||||
// fill-column: 80
|
|
||||||
// End:
|
|
||||||
|
|
@ -2,17 +2,13 @@
|
||||||
// t-eoLogger.cpp
|
// t-eoLogger.cpp
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <utils/eoLogger.h>
|
|
||||||
#include <utils/eoParserLogger.h>
|
|
||||||
|
|
||||||
#include <eo>
|
#include <eo>
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
int main(int ac, char** av)
|
int main(int ac, char** av)
|
||||||
{
|
{
|
||||||
eoParserLogger parser(ac, av);
|
eoParser parser(ac, av);
|
||||||
|
|
||||||
if (parser.userNeedsHelp())
|
if (parser.userNeedsHelp())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,6 @@ Caner Candan <caner.candan@thalesgroup.com>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
|
||||||
#include <utils/eoLogger.h>
|
|
||||||
#include <utils/eoParserLogger.h>
|
|
||||||
|
|
||||||
#include <eo>
|
#include <eo>
|
||||||
#include <es/make_real.h>
|
#include <es/make_real.h>
|
||||||
|
|
||||||
|
|
@ -114,7 +111,7 @@ void measure( size_t p,
|
||||||
|
|
||||||
int main(int ac, char** av)
|
int main(int ac, char** av)
|
||||||
{
|
{
|
||||||
eoParserLogger parser(ac, av);
|
eoParser parser(ac, av);
|
||||||
|
|
||||||
unsigned int popMin = parser.getORcreateParam((unsigned int)1, "popMin", "Population Min", 'p', "Evolution Engine").value();
|
unsigned int popMin = parser.getORcreateParam((unsigned int)1, "popMin", "Population Min", 'p', "Evolution Engine").value();
|
||||||
unsigned int popStep = parser.getORcreateParam((unsigned int)1, "popStep", "Population Step", 0, "Evolution Engine").value();
|
unsigned int popStep = parser.getORcreateParam((unsigned int)1, "popStep", "Population Step", 0, "Evolution Engine").value();
|
||||||
|
|
|
||||||
Reference in a new issue