1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-10 08:55:37 +00:00

code cleaning

This commit is contained in:
Antonin Portelli 2014-02-20 22:54:11 +00:00
parent 5a3f6a6106
commit 9ce04cd7d6
23 changed files with 42 additions and 87 deletions

View File

@ -27,7 +27,7 @@ using namespace Latan;
/****************************************************************************** /******************************************************************************
* Compiled double function implementation * * Compiled double function implementation *
******************************************************************************/ ******************************************************************************/
// constructor ///////////////////////////////////////////////////////////////// // constructors ////////////////////////////////////////////////////////////////
CompiledDoubleFunction::CompiledDoubleFunction(const unsigned nArg) CompiledDoubleFunction::CompiledDoubleFunction(const unsigned nArg)
: DoubleFunction(nArg) : DoubleFunction(nArg)
{} {}
@ -39,10 +39,6 @@ CompiledDoubleFunction::CompiledDoubleFunction(const unsigned nArg,
setCode(code); setCode(code);
} }
// destructor //////////////////////////////////////////////////////////////////
CompiledDoubleFunction::~CompiledDoubleFunction(void)
{}
// access ////////////////////////////////////////////////////////////////////// // access //////////////////////////////////////////////////////////////////////
void CompiledDoubleFunction::setCode(const string &code) void CompiledDoubleFunction::setCode(const string &code)
{ {

View File

@ -41,7 +41,7 @@ public:
explicit CompiledDoubleFunction(const unsigned nArg, explicit CompiledDoubleFunction(const unsigned nArg,
const std::string &code); const std::string &code);
// destructor // destructor
virtual ~CompiledDoubleFunction(void); virtual ~CompiledDoubleFunction(void) = default;
// access // access
void setCode(const std::string &code); void setCode(const std::string &code);
// function call // function call

View File

@ -38,12 +38,12 @@ class Dataset: public StatArray<T>
private: private:
typedef StatArray<T> Base; typedef StatArray<T> Base;
public: public:
// constructor // constructors
using Base::Base; using Base::Base;
Dataset(void); Dataset(void);
Dataset(const std::string &listFileName, const std::string &dataName); Dataset(const std::string &listFileName, const std::string &dataName);
// destructor // destructor
virtual ~Dataset(void); virtual ~Dataset(void) = default;
// IO // IO
void load(const std::string &listFileName, const std::string &dataName); void load(const std::string &listFileName, const std::string &dataName);
// resampling // resampling
@ -70,11 +70,6 @@ Dataset<T, FileType>::Dataset(const std::string &listFileName,
load(listFileName, dataName); load(listFileName, dataName);
} }
// destructor //////////////////////////////////////////////////////////////////
template <typename T, typename FileType>
Dataset<T, FileType>::~Dataset(void)
{}
// IO ////////////////////////////////////////////////////////////////////////// // IO //////////////////////////////////////////////////////////////////////////
template <typename T, typename FileType> template <typename T, typename FileType>
void Dataset<T, FileType>::load(const std::string &listFileName, void Dataset<T, FileType>::load(const std::string &listFileName,

View File

@ -33,18 +33,14 @@ using namespace std;
using namespace Latan; using namespace Latan;
using namespace Exceptions; using namespace Exceptions;
// prefix for messages
const string Latan::Exceptions::prefix = "[" + strFrom(PACKAGE_NAME) + " v"
+ strFrom(PACKAGE_VERSION) + "] ";
// logic errors // logic errors
CONST_EXC(Logic, logic_error(prefix + msg + ERR_SUFF)) CONST_EXC(Logic, logic_error(Env::msgPrefix + msg + ERR_SUFF))
CONST_EXC(Definition, Logic("definition error: " + msg, loc)) CONST_EXC(Definition, Logic("definition error: " + msg, loc))
CONST_EXC(Implementation, Logic("implementation error: " + msg, loc)) CONST_EXC(Implementation, Logic("implementation error: " + msg, loc))
CONST_EXC(Range, Logic("range error: " + msg, loc)) CONST_EXC(Range, Logic("range error: " + msg, loc))
CONST_EXC(Size, Logic("size error: " + msg, loc)) CONST_EXC(Size, Logic("size error: " + msg, loc))
// runtime errors // runtime errors
CONST_EXC(Runtime, runtime_error(prefix + msg + ERR_SUFF)) CONST_EXC(Runtime, runtime_error(Env::msgPrefix + msg + ERR_SUFF))
CONST_EXC(Compilation, Runtime("compilation error: " + msg, loc)) CONST_EXC(Compilation, Runtime("compilation error: " + msg, loc))
CONST_EXC(Io, Runtime("IO error: " + msg, loc)) CONST_EXC(Io, Runtime("IO error: " + msg, loc))
CONST_EXC(Parsing, Runtime(msg, loc)) CONST_EXC(Parsing, Runtime(msg, loc))

View File

@ -29,7 +29,7 @@
+ strFrom(__LINE__) + strFrom(__LINE__)
#define LATAN_ERROR(exc,msg) throw(Exceptions::exc(msg, SRC_LOC)) #define LATAN_ERROR(exc,msg) throw(Exceptions::exc(msg, SRC_LOC))
#define LATAN_WARNING(msg) \ #define LATAN_WARNING(msg) \
std::cerr << Latan::Exceptions::prefix << "warning: " << msg\ std::cerr << Env::msgPrefix << "warning: " << msg\
<< " (" << SRC_LOC << ")" << std::endl << " (" << SRC_LOC << ")" << std::endl
#define DECL_EXC(name, base) \ #define DECL_EXC(name, base) \
@ -43,9 +43,6 @@ BEGIN_NAMESPACE
namespace Exceptions namespace Exceptions
{ {
// prefix for messages
extern const std::string prefix;
// logic errors // logic errors
DECL_EXC(Logic, std::logic_error); DECL_EXC(Logic, std::logic_error);
DECL_EXC(Definition, Logic); DECL_EXC(Definition, Logic);

View File

@ -44,14 +44,11 @@ using namespace Latan;
/****************************************************************************** /******************************************************************************
* Function implementation * * Function implementation *
******************************************************************************/ ******************************************************************************/
// constructor/destructor ////////////////////////////////////////////////////// // constructor /////////////////////////////////////////////////////////////////
Function::Function(const unsigned nArg) Function::Function(const unsigned nArg)
: nArg_(nArg) : nArg_(nArg)
{} {}
Function::~Function(void)
{}
// access ////////////////////////////////////////////////////////////////////// // access //////////////////////////////////////////////////////////////////////
unsigned int Function::getNArg(void) const unsigned int Function::getNArg(void) const
{ {
@ -61,15 +58,14 @@ unsigned int Function::getNArg(void) const
/****************************************************************************** /******************************************************************************
* DoubleFunction implementation * * DoubleFunction implementation *
******************************************************************************/ ******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
DoubleFunction::DoubleFunction(const unsigned nArg, vecFunc f) DoubleFunction::DoubleFunction(const unsigned nArg, vecFunc f)
: Function(nArg) : Function(nArg)
, buffer_(new vector<double>(nArg)) , buffer_(new vector<double>(nArg))
, f_(f) , f_(f)
{} {}
DoubleFunction::~DoubleFunction(void) // function call ///////////////////////////////////////////////////////////////
{}
double DoubleFunction::evaluate(const std::vector<double> &arg) const double DoubleFunction::evaluate(const std::vector<double> &arg) const
{ {
return f_(arg); return f_(arg);

View File

@ -35,9 +35,10 @@ BEGIN_NAMESPACE
class Function class Function
{ {
public: public:
// constructor/destructor // constructor
explicit Function(const unsigned nArg); explicit Function(const unsigned nArg);
virtual ~Function(void); // destructor
virtual ~Function(void) = default;
// access // access
unsigned int getNArg(void) const; unsigned int getNArg(void) const;
private: private:
@ -52,9 +53,10 @@ class DoubleFunction: public Function
private: private:
typedef std::function<double(const std::vector<double> &)> vecFunc; typedef std::function<double(const std::vector<double> &)> vecFunc;
public: public:
// constructor/destructor // constructor
explicit DoubleFunction(const unsigned nArg, vecFunc f = nullptr); explicit DoubleFunction(const unsigned nArg, vecFunc f = nullptr);
virtual ~DoubleFunction(void); // destructor
virtual ~DoubleFunction(void) = default;
// function call // function call
virtual double evaluate(const std::vector<double> &arg) const; virtual double evaluate(const std::vector<double> &arg) const;
double operator()(std::stack<double> &arg) const; double operator()(std::stack<double> &arg) const;

View File

@ -26,3 +26,5 @@ using namespace Latan;
const string Env::fullName = PACKAGE_STRING; const string Env::fullName = PACKAGE_STRING;
const string Env::name = PACKAGE_NAME; const string Env::name = PACKAGE_NAME;
const string Env::version = PACKAGE_VERSION; const string Env::version = PACKAGE_VERSION;
const string Env::msgPrefix = "[" + strFrom(PACKAGE_NAME) + " v"
+ strFrom(PACKAGE_VERSION) + "] ";

View File

@ -59,6 +59,7 @@ namespace Env
extern const std::string fullName; extern const std::string fullName;
extern const std::string name; extern const std::string name;
extern const std::string version; extern const std::string version;
extern const std::string msgPrefix;
} }
// pointer type test // pointer type test

View File

@ -36,7 +36,7 @@
BEGIN_NAMESPACE BEGIN_NAMESPACE
/****************************************************************************** /******************************************************************************
* Generic datafile class * * Abstract datafile class *
******************************************************************************/ ******************************************************************************/
typedef std::unordered_map<std::string, std::unique_ptr<IoObject>> IoDataTable; typedef std::unordered_map<std::string, std::unique_ptr<IoObject>> IoDataTable;

View File

@ -36,7 +36,9 @@ public:
rgState = 3 rgState = 3
}; };
public: public:
virtual ~IoObject(void) {}; // destructor
virtual ~IoObject(void) = default;
// access
virtual IoType getType(void) const = 0; virtual IoType getType(void) const = 0;
}; };

View File

@ -37,6 +37,8 @@ public:
DMat(void); DMat(void);
DMat(const unsigned int nRow, const unsigned int nCol); DMat(const unsigned int nRow, const unsigned int nCol);
EIGEN_EXPR_CTOR(DMat, DMat, Base, MatrixBase) EIGEN_EXPR_CTOR(DMat, DMat, Base, MatrixBase)
// destructor
virtual ~DMat(void) = default;
// IO // IO
virtual IoType getType(void) const; virtual IoType getType(void) const;
}; };

View File

@ -400,10 +400,6 @@ MathInterpreter::MathInterpreter(const std::string &code)
setCode(code); setCode(code);
} }
// destructor //////////////////////////////////////////////////////////////////
MathInterpreter::~MathInterpreter(void)
{}
// access ////////////////////////////////////////////////////////////////////// // access //////////////////////////////////////////////////////////////////////
const Instruction * MathInterpreter::operator[](const unsigned int i) const const Instruction * MathInterpreter::operator[](const unsigned int i) const
{ {

View File

@ -239,7 +239,7 @@ public:
MathInterpreter(void); MathInterpreter(void);
MathInterpreter(const std::string &code); MathInterpreter(const std::string &code);
// destructor // destructor
~MathInterpreter(void); ~MathInterpreter(void) = default;
// access // access
const Instruction * operator[](const unsigned int i) const; const Instruction * operator[](const unsigned int i) const;
const ExprNode * getAST(void) const; const ExprNode * getAST(void) const;

View File

@ -34,7 +34,7 @@ public:
explicit ParserState(std::istream *streamPt, std::string *namePt, explicit ParserState(std::istream *streamPt, std::string *namePt,
DataObj *dataPt); DataObj *dataPt);
// destructor // destructor
virtual ~ParserState(void); virtual ~ParserState(void) = default;
private: private:
// scanner allocation/deallocation // scanner allocation/deallocation
virtual void initScanner(void) = 0; virtual void initScanner(void) = 0;
@ -56,10 +56,6 @@ ParserState<DataObj>::ParserState(std::istream *streamPt, std::string *namePt,
, streamName(namePt) , streamName(namePt)
{} {}
template <typename DataObj>
ParserState<DataObj>::~ParserState(void)
{}
END_NAMESPACE END_NAMESPACE
#endif // Latan_ParserState_hpp_ #endif // Latan_ParserState_hpp_

View File

@ -36,17 +36,12 @@ PlotCommand::PlotCommand(const string &command)
: command_(command) : command_(command)
{} {}
// destructor //////////////////////////////////////////////////////////////////
PlotCommand::~PlotCommand(void)
{}
// access ////////////////////////////////////////////////////////////////////// // access //////////////////////////////////////////////////////////////////////
const std::string & PlotCommand::getCommand(void) const const std::string & PlotCommand::getCommand(void) const
{ {
return command_; return command_;
} }
/****************************************************************************** /******************************************************************************
* Plot implementation * * Plot implementation *
******************************************************************************/ ******************************************************************************/

View File

@ -42,10 +42,11 @@ BEGIN_NAMESPACE
class PlotCommand class PlotCommand
{ {
public: public:
// constructors/destructor // constructors
PlotCommand(void); PlotCommand(void);
PlotCommand(const std::string &command); PlotCommand(const std::string &command);
virtual ~PlotCommand(void); // destructor
virtual ~PlotCommand(void) = default;
// access // access
virtual const std::string & getCommand(void) const; virtual const std::string & getCommand(void) const;
protected: protected:

View File

@ -30,13 +30,11 @@ using namespace Latan;
/****************************************************************************** /******************************************************************************
* RandGen implementation * * RandGen implementation *
******************************************************************************/ ******************************************************************************/
// State implentation ////////////////////////////////////////////////////////// // State constructor ///////////////////////////////////////////////////////////
RandGen::State::State(void) RandGen::State::State(void)
{} {}
RandGen::State::~State(void) // State IO type ///////////////////////////////////////////////////////////////
{}
IoObject::IoType RandGen::State::getType(void) const IoObject::IoType RandGen::State::getType(void) const
{ {
return IoType::rgState; return IoType::rgState;
@ -647,10 +645,6 @@ RandGen::RandGen(const State &state)
setState(state); setState(state);
} }
// destructor //////////////////////////////////////////////////////////////////
RandGen::~RandGen(void)
{}
// state management //////////////////////////////////////////////////////////// // state management ////////////////////////////////////////////////////////////
RandGen::State RandGen::getState(void) const RandGen::State RandGen::getState(void) const
{ {

View File

@ -42,7 +42,7 @@ public:
// constructor // constructor
State(void); State(void);
// destructor // destructor
~State(void); virtual ~State(void) = default;
// IO type // IO type
IoType getType(void) const; IoType getType(void) const;
}; };
@ -61,6 +61,7 @@ private:
} rlxd_dble_vec_t __attribute__ ((aligned (16))); } rlxd_dble_vec_t __attribute__ ((aligned (16)));
public: public:
RanLxd(void); RanLxd(void);
~RanLxd(void) = default;
void ranlxd(double r[],int n); void ranlxd(double r[],int n);
void rlxd_init(int level,int seed); void rlxd_init(int level,int seed);
int rlxd_size(void) const; int rlxd_size(void) const;
@ -86,7 +87,7 @@ public:
RandGen(const int seed); RandGen(const int seed);
RandGen(const State &state); RandGen(const State &state);
// destructor // destructor
virtual ~RandGen(void); virtual ~RandGen(void) = default;
// state management // state management
State getState(void) const; State getState(void) const;
void setState(const State &state); void setState(const State &state);

View File

@ -38,10 +38,6 @@ DMatSample::DMatSample(const unsigned int nSample, const unsigned int nRow,
resizeMat(nRow, nCol); resizeMat(nRow, nCol);
} }
// destructor //////////////////////////////////////////////////////////////////
DMatSample::~DMatSample(void)
{}
// resize all matrices ///////////////////////////////////////////////////////// // resize all matrices /////////////////////////////////////////////////////////
void DMatSample::resizeMat(const unsigned int nRow, const unsigned int nCol) void DMatSample::resizeMat(const unsigned int nRow, const unsigned int nCol)
{ {

View File

@ -43,7 +43,7 @@ public:
// constructors // constructors
using Base::Base; using Base::Base;
// destructor // destructor
virtual ~Sample(void); virtual ~Sample(void) = default;
}; };
/****************************************************************************** /******************************************************************************
@ -58,21 +58,13 @@ public:
const unsigned int nCol); const unsigned int nCol);
using Sample<DMat>::Sample; using Sample<DMat>::Sample;
// destructor // destructor
virtual ~DMatSample(void); virtual ~DMatSample(void) = default;
// resize all matrices // resize all matrices
void resizeMat(const unsigned int nRow, const unsigned int nCol); void resizeMat(const unsigned int nRow, const unsigned int nCol);
// IO type // IO type
virtual IoType getType(void) const; virtual IoType getType(void) const;
}; };
/******************************************************************************
* Sample class template implementation *
******************************************************************************/
// destructor //////////////////////////////////////////////////////////////////
template <typename T>
Sample<T>::~Sample(void)
{}
END_NAMESPACE END_NAMESPACE
#endif // Latan_Sample_hpp_ #endif // Latan_Sample_hpp_

View File

@ -41,7 +41,7 @@ public:
EIGEN_EXPR_CTOR(StatArray, unique_arg(StatArray<T, offset>), Base, EIGEN_EXPR_CTOR(StatArray, unique_arg(StatArray<T, offset>), Base,
ArrayBase) ArrayBase)
// destructor // destructor
virtual ~StatArray(void); virtual ~StatArray(void) = default;
// access // access
unsigned int size(void) const; unsigned int size(void) const;
// operators // operators
@ -80,11 +80,6 @@ StatArray<T, offset>::StatArray(const unsigned int size)
: Base(static_cast<typename Base::Index>(size + offset)) : Base(static_cast<typename Base::Index>(size + offset))
{} {}
// destructor //////////////////////////////////////////////////////////////////
template <typename T, unsigned int offset>
StatArray<T, offset>::~StatArray(void)
{}
// access ////////////////////////////////////////////////////////////////////// // access //////////////////////////////////////////////////////////////////////
template <typename T, unsigned int offset> template <typename T, unsigned int offset>
unsigned int StatArray<T, offset>::size(void) const unsigned int StatArray<T, offset>::size(void) const