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
|
||||
|
||||
mkdir release
|
||||
mkdir -p release
|
||||
cd release
|
||||
cmake -DENABLE_EO_TUTORIAL=1 ..
|
||||
make
|
||||
|
|
|
|||
|
|
@ -199,8 +199,7 @@
|
|||
#include <eoLinearDecreasingWeightUp.h>
|
||||
#include <eoGaussRealWeightUp.h>
|
||||
|
||||
#include <utils/eoParserLogger.h>
|
||||
|
||||
#include <utils/eoLogger.h>
|
||||
#include <utils/eoParallel.h>
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ 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 (ES_SOURCES make_algo_scalar_es.cpp
|
||||
SET(ES_SOURCES
|
||||
make_algo_scalar_es.cpp
|
||||
make_algo_scalar_real.cpp
|
||||
make_checkpoint_es.cpp
|
||||
make_checkpoint_real.cpp
|
||||
|
|
@ -27,12 +28,14 @@ SET (ES_SOURCES make_algo_scalar_es.cpp
|
|||
make_pop_es.cpp
|
||||
make_pop_real.cpp
|
||||
make_run_es.cpp
|
||||
make_run_real.cpp)
|
||||
make_run_real.cpp
|
||||
)
|
||||
|
||||
SET (CMA_SOURCES eig.cpp
|
||||
SET(CMA_SOURCES
|
||||
eig.cpp
|
||||
CMAState.cpp
|
||||
CMAParams.cpp)
|
||||
|
||||
CMAParams.cpp
|
||||
)
|
||||
|
||||
ADD_LIBRARY(es STATIC ${ES_SOURCES})
|
||||
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}")
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
|
|
|||
|
|
@ -12,14 +12,15 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
|||
SET(GA_LIB_OUTPUT_PATH ${EO_BINARY_DIR}/lib)
|
||||
SET(LIBRARY_OUTPUT_PATH ${GA_LIB_OUTPUT_PATH})
|
||||
|
||||
SET (GA_SOURCES make_algo_scalar_ga.cpp
|
||||
SET(GA_SOURCES
|
||||
make_algo_scalar_ga.cpp
|
||||
make_checkpoint_ga.cpp
|
||||
make_continue_ga.cpp
|
||||
make_genotype_ga.cpp
|
||||
make_op_ga.cpp
|
||||
make_pop_ga.cpp
|
||||
make_run_ga.cpp)
|
||||
|
||||
make_run_ga.cpp
|
||||
)
|
||||
|
||||
ADD_LIBRARY(ga STATIC ${GA_SOURCES})
|
||||
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}")
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,2 @@
|
|||
FILE(GLOB HDRS *.h)
|
||||
INSTALL(FILES ${HDRS} DESTINATION include/eo/gp COMPONENT headers)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
|||
SET(EOUTILS_LIB_OUTPUT_PATH ${EO_BINARY_DIR}/lib)
|
||||
SET(LIBRARY_OUTPUT_PATH ${EOUTILS_LIB_OUTPUT_PATH})
|
||||
|
||||
SET (EOUTILS_SOURCES eoData.cpp
|
||||
SET(EOUTILS_SOURCES
|
||||
eoData.cpp
|
||||
eoFileMonitor.cpp
|
||||
eoGnuplot.cpp
|
||||
eoGnuplot1DMonitor.cpp
|
||||
|
|
@ -27,9 +28,8 @@ SET (EOUTILS_SOURCES eoData.cpp
|
|||
make_help.cpp
|
||||
pipecom.cpp
|
||||
eoLogger.cpp
|
||||
eoParserLogger.cpp
|
||||
eoParallel.cpp)
|
||||
|
||||
eoParallel.cpp
|
||||
)
|
||||
|
||||
ADD_LIBRARY(eoutils STATIC ${EOUTILS_SOURCES})
|
||||
INSTALL(TARGETS eoutils ARCHIVE DESTINATION lib COMPONENT libraries)
|
||||
|
|
|
|||
|
|
@ -26,30 +26,31 @@ Authors:
|
|||
|
||||
*/
|
||||
|
||||
#ifdef _INTERIX
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#else // _INTERIX
|
||||
#else // _WIN32
|
||||
#include <unistd.h>
|
||||
#endif // ! _INTERIX
|
||||
#endif // ! _WIN32
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <cstdlib>
|
||||
#include <cstdio> // used to define EOF
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <locale>
|
||||
|
||||
#include "eoLogger.h"
|
||||
|
||||
eoLogger eo::log;
|
||||
eoLogger::eoLogger() :
|
||||
std::ostream(&_obuf),
|
||||
|
||||
eoLogger::eoLogger()
|
||||
: std::ostream(&_obuf),
|
||||
_selectedLevel(eo::progress), _contextLevel(eo::quiet),
|
||||
_fd(2), _obuf(_fd, _contextLevel, _selectedLevel)
|
||||
_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'),
|
||||
|
||||
_selectedLevel(eo::progress),
|
||||
_contextLevel(eo::quiet),
|
||||
_fd(2),
|
||||
_obuf(_fd, _contextLevel, _selectedLevel)
|
||||
{
|
||||
_standard_io_streams[&std::cout] = 1;
|
||||
_standard_io_streams[&std::clog] = 2;
|
||||
|
|
@ -71,6 +72,44 @@ eoLogger::~eoLogger()
|
|||
if (_fd > 2) { ::close(_fd); }
|
||||
}
|
||||
|
||||
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");
|
||||
|
|
@ -134,7 +173,7 @@ int eoLogger::outbuf::overflow(int_type c)
|
|||
{
|
||||
if (_fd >= 0 && c != EOF)
|
||||
{
|
||||
ssize_t num;
|
||||
size_t num;
|
||||
num = ::write(_fd, &c, 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -155,3 +194,13 @@ namespace eo
|
|||
: _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:
|
||||
\code
|
||||
#include <iostream>
|
||||
#include <utils/eoLogger.h>
|
||||
#include <utils/eoParserLogger.h>
|
||||
#include <eo>
|
||||
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
// We are declaring first an overload of eoParser class using Logger
|
||||
// component.
|
||||
eoParserLogger parser(ac, av);
|
||||
// We are declaring the usual eoParser class
|
||||
eoParser parser(ac, av);
|
||||
|
||||
// This call is important to allow -v parameter to change user level.
|
||||
make_verbose(parser);
|
||||
|
|
@ -96,7 +93,7 @@ Caner Candan <caner.candan@thalesgroup.com>
|
|||
#include <iosfwd>
|
||||
|
||||
#include "eoObject.h"
|
||||
|
||||
#include "eoParser.h"
|
||||
|
||||
namespace eo
|
||||
{
|
||||
|
|
@ -158,16 +155,19 @@ public:
|
|||
* Use this function if you want to be able to compare selected levels to a given one, like:
|
||||
* 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
|
||||
* the one given when you output message with the logger
|
||||
*/
|
||||
eo::Levels getLevelContext() const { return _contextLevel; }
|
||||
inline eo::Levels getLevelContext() const { return _contextLevel; }
|
||||
|
||||
protected:
|
||||
void addLevel(std::string name, eo::Levels level);
|
||||
|
||||
private:
|
||||
void _createParameters( eoParser& );
|
||||
|
||||
private:
|
||||
/**
|
||||
* outbuf
|
||||
|
|
@ -176,9 +176,7 @@ private:
|
|||
class outbuf : public std::streambuf
|
||||
{
|
||||
public:
|
||||
outbuf(const int& fd,
|
||||
const eo::Levels& contexlvl,
|
||||
const eo::Levels& selectedlvl);
|
||||
outbuf(const int& fd, const eo::Levels& contexlvl, const eo::Levels& selectedlvl);
|
||||
protected:
|
||||
virtual int overflow(int_type c);
|
||||
private:
|
||||
|
|
@ -215,6 +213,12 @@ public:
|
|||
friend eoLogger& operator<<(eoLogger&, std::ostream&);
|
||||
|
||||
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()
|
||||
*/
|
||||
|
|
@ -250,6 +254,8 @@ private:
|
|||
/** @example t-eoLogger.cpp
|
||||
*/
|
||||
|
||||
void make_verbose(eoParser&);
|
||||
|
||||
namespace eo
|
||||
{
|
||||
/**
|
||||
|
|
@ -258,7 +264,6 @@ namespace eo
|
|||
extern eoLogger log;
|
||||
}
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#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
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <iostream>
|
||||
#include <utils/eoLogger.h>
|
||||
#include <utils/eoParserLogger.h>
|
||||
|
||||
#include <eo>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
eoParserLogger parser(ac, av);
|
||||
eoParser parser(ac, av);
|
||||
|
||||
if (parser.userNeedsHelp())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,9 +32,6 @@ Caner Candan <caner.candan@thalesgroup.com>
|
|||
#include <sstream>
|
||||
#include <climits>
|
||||
|
||||
#include <utils/eoLogger.h>
|
||||
#include <utils/eoParserLogger.h>
|
||||
|
||||
#include <eo>
|
||||
#include <es/make_real.h>
|
||||
|
||||
|
|
@ -114,7 +111,7 @@ void measure( size_t p,
|
|||
|
||||
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 popStep = parser.getORcreateParam((unsigned int)1, "popStep", "Population Step", 0, "Evolution Engine").value();
|
||||
|
|
|
|||
Reference in a new issue