removed CRLF (-> LF) from older files in tools-subfolder
This commit is contained in:
parent
c07eb52f30
commit
6de275a593
300
tools/AdrOp.h
300
tools/AdrOp.h
@ -1,150 +1,150 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de)
|
* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de)
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class AdrOp
|
\class AdrOp
|
||||||
\author Thorsten Liebig
|
\author Thorsten Liebig
|
||||||
\version $Revision: 1.10 $
|
\version $Revision: 1.10 $
|
||||||
\date $Date: 2006/10/29 18:50:44 $
|
\date $Date: 2006/10/29 18:50:44 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ADROP_H
|
#ifndef ADROP_H
|
||||||
#define ADROP_H
|
#define ADROP_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "ExpenseLog.h"
|
#include "ExpenseLog.h"
|
||||||
#include "ErrorMsg.h"
|
#include "ErrorMsg.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class AdrOp{
|
class AdrOp{
|
||||||
public:
|
public:
|
||||||
///Constructor, define dimension/size here
|
///Constructor, define dimension/size here
|
||||||
AdrOp(unsigned int muiImax, unsigned int muiYmax, unsigned int muiKmax=0, unsigned int muiLmax=0);
|
AdrOp(unsigned int muiImax, unsigned int muiYmax, unsigned int muiKmax=0, unsigned int muiLmax=0);
|
||||||
///Copy-Constructor
|
///Copy-Constructor
|
||||||
AdrOp(AdrOp* origOP);
|
AdrOp(AdrOp* origOP);
|
||||||
///Deconstructor
|
///Deconstructor
|
||||||
virtual ~AdrOp();
|
virtual ~AdrOp();
|
||||||
///Set the current n-dim position, get 1-dim array position as return value
|
///Set the current n-dim position, get 1-dim array position as return value
|
||||||
/*!A position has to be set or all other methodes will case error! \n The methode will exit with error message if invalid position is set! \sa ErrorMsg */
|
/*!A position has to be set or all other methodes will case error! \n The methode will exit with error message if invalid position is set! \sa ErrorMsg */
|
||||||
unsigned int SetPos(unsigned int muiIpos, unsigned int muiJpos, unsigned int muiKpos=0, unsigned int muiLpos=0);
|
unsigned int SetPos(unsigned int muiIpos, unsigned int muiJpos, unsigned int muiKpos=0, unsigned int muiLpos=0);
|
||||||
|
|
||||||
bool SetPosChecked(unsigned int muiIpos, unsigned int muiJpos, unsigned int muiKpos=0, unsigned int muiLpos=0);
|
bool SetPosChecked(unsigned int muiIpos, unsigned int muiJpos, unsigned int muiKpos=0, unsigned int muiLpos=0);
|
||||||
|
|
||||||
void SetGrid(double *gridI,double *gridJ,double *gridK=NULL,double *gridL=NULL);
|
void SetGrid(double *gridI,double *gridJ,double *gridK=NULL,double *gridL=NULL);
|
||||||
void SetGridDelta(double delta) {this->dDeltaUnit=delta;};
|
void SetGridDelta(double delta) {this->dDeltaUnit=delta;};
|
||||||
|
|
||||||
bool CheckPos(unsigned int muiIpos, unsigned int muiJpos, unsigned int muiKpos=0, unsigned int muiLpos=0);
|
bool CheckPos(unsigned int muiIpos, unsigned int muiJpos, unsigned int muiKpos=0, unsigned int muiLpos=0);
|
||||||
bool CheckRelativePos(int muiIrel=0,int muiJrel=0,int muiKrel=0, int muiLrel=0);
|
bool CheckRelativePos(int muiIrel=0,int muiJrel=0,int muiKrel=0, int muiLrel=0);
|
||||||
///will return current 1-dim position, in addition to a relative n-dim shift
|
///will return current 1-dim position, in addition to a relative n-dim shift
|
||||||
/*!In case of crossing the boundaries, activate reflection or an error will be invoked\sa SetReflection2Node \sa SetReflection2Cell \sa SetReflectionOff */
|
/*!In case of crossing the boundaries, activate reflection or an error will be invoked\sa SetReflection2Node \sa SetReflection2Cell \sa SetReflectionOff */
|
||||||
unsigned int GetPos(int muiIrel=0,int muiJrel=0,int muiKrel=0, int muiLrel=0);
|
unsigned int GetPos(int muiIrel=0,int muiJrel=0,int muiKrel=0, int muiLrel=0);
|
||||||
|
|
||||||
double GetNodeVolume(unsigned int uiNode);
|
double GetNodeVolume(unsigned int uiNode);
|
||||||
|
|
||||||
double GetIndexWidth(int ny, int index);
|
double GetIndexWidth(int ny, int index);
|
||||||
double GetIndexCoord(int ny, int index);
|
double GetIndexCoord(int ny, int index);
|
||||||
///Get the gird delta at the given index of direction ny. (if index<0 return negative value as index=0 would give, if index>=max-1 returns negative value as index=max-2 would give)
|
///Get the gird delta at the given index of direction ny. (if index<0 return negative value as index=0 would give, if index>=max-1 returns negative value as index=max-2 would give)
|
||||||
double GetIndexDelta(int ny, int index);
|
double GetIndexDelta(int ny, int index);
|
||||||
|
|
||||||
// double GetCellVolume(unsigned int uiCell);
|
// double GetCellVolume(unsigned int uiCell);
|
||||||
|
|
||||||
unsigned int GetPosFromNode(int ny, unsigned int uiNode);
|
unsigned int GetPosFromNode(int ny, unsigned int uiNode);
|
||||||
///Set a shift in ny direction (e.g. 0 for i-direction)
|
///Set a shift in ny direction (e.g. 0 for i-direction)
|
||||||
/*!Shift set by this methode will be ignored by methode GetPos*/
|
/*!Shift set by this methode will be ignored by methode GetPos*/
|
||||||
unsigned int Shift(int ny, int step);
|
unsigned int Shift(int ny, int step);
|
||||||
///Set a checked shift in ny direction (e.g. 0 for i-direction)
|
///Set a checked shift in ny direction (e.g. 0 for i-direction)
|
||||||
/*!Shift set by this methode will be ignored by methode GetPos*/
|
/*!Shift set by this methode will be ignored by methode GetPos*/
|
||||||
bool CheckShift(int ny, int step);
|
bool CheckShift(int ny, int step);
|
||||||
///Returns the current 1-dim position including shift by methode "Shift"
|
///Returns the current 1-dim position including shift by methode "Shift"
|
||||||
unsigned int GetShiftedPos();
|
unsigned int GetShiftedPos();
|
||||||
///Reset shift set by "Shift"-methode
|
///Reset shift set by "Shift"-methode
|
||||||
void ResetShift();
|
void ResetShift();
|
||||||
///Iterates through AdrOp; --- obsolete ---
|
///Iterates through AdrOp; --- obsolete ---
|
||||||
unsigned int Iterate(int jump=1);
|
unsigned int Iterate(int jump=1);
|
||||||
///Retruns size of array
|
///Retruns size of array
|
||||||
unsigned int GetSize();
|
unsigned int GetSize();
|
||||||
///Set mode to reflect by node
|
///Set mode to reflect by node
|
||||||
/*!1D-example (6 nodes): \image html node_reflect.PNG order: 0,1,2,3,4,5,4,3,...*/
|
/*!1D-example (6 nodes): \image html node_reflect.PNG order: 0,1,2,3,4,5,4,3,...*/
|
||||||
void SetReflection2Node();
|
void SetReflection2Node();
|
||||||
///Set mode to reflect by cell
|
///Set mode to reflect by cell
|
||||||
/*!1D-example (5 cells): \image html cell_reflect.PNG order: 0,1,2,3,4,4,3,...*/
|
/*!1D-example (5 cells): \image html cell_reflect.PNG order: 0,1,2,3,4,4,3,...*/
|
||||||
void SetReflection2Cell();
|
void SetReflection2Cell();
|
||||||
///Deactivate reflection (default)
|
///Deactivate reflection (default)
|
||||||
void SetReflectionOff();
|
void SetReflectionOff();
|
||||||
///Add a cell adress operator (dimensions: i-1 j-1 k-1 l-1)
|
///Add a cell adress operator (dimensions: i-1 j-1 k-1 l-1)
|
||||||
/*!\image html cells_nodes.png */
|
/*!\image html cells_nodes.png */
|
||||||
AdrOp* AddCellAdrOp();
|
AdrOp* AddCellAdrOp();
|
||||||
|
|
||||||
AdrOp* GetCellAdrOp() {return clCellAdr;};
|
AdrOp* GetCellAdrOp() {return clCellAdr;};
|
||||||
|
|
||||||
///Deconstructed cell adress operator if no longer needed
|
///Deconstructed cell adress operator if no longer needed
|
||||||
AdrOp* DeleteCellAdrOp();
|
AdrOp* DeleteCellAdrOp();
|
||||||
///Shift cell in ny dircetion; cell reflection is active
|
///Shift cell in ny dircetion; cell reflection is active
|
||||||
unsigned int ShiftCell(int ny, int step);
|
unsigned int ShiftCell(int ny, int step);
|
||||||
///Shift cell in ny dircetion; cell reflection is active; return check
|
///Shift cell in ny dircetion; cell reflection is active; return check
|
||||||
bool ShiftCellCheck(int ny, int step);
|
bool ShiftCellCheck(int ny, int step);
|
||||||
///Reset cell shift
|
///Reset cell shift
|
||||||
void ResetCellShift();
|
void ResetCellShift();
|
||||||
///Get current cell position from cell adress operator
|
///Get current cell position from cell adress operator
|
||||||
unsigned int GetCellPos(bool incShift=true);
|
unsigned int GetCellPos(bool incShift=true);
|
||||||
///Get cell position from cell adress operator
|
///Get cell position from cell adress operator
|
||||||
unsigned int GetCellPos(int i, int j, int k=0);
|
unsigned int GetCellPos(int i, int j, int k=0);
|
||||||
//get volume of cell; incl shift
|
//get volume of cell; incl shift
|
||||||
double GetShiftCellVolume(int ny, int step);
|
double GetShiftCellVolume(int ny, int step);
|
||||||
|
|
||||||
|
|
||||||
void SetDebugOn() {this->bDebug=true;};
|
void SetDebugOn() {this->bDebug=true;};
|
||||||
void SetDebugOff() {this->bDebug=false;};
|
void SetDebugOff() {this->bDebug=false;};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AdrOp *clCellAdr;
|
AdrOp *clCellAdr;
|
||||||
unsigned int uiDimension;
|
unsigned int uiDimension;
|
||||||
unsigned int uiSize;
|
unsigned int uiSize;
|
||||||
unsigned int uiImax,uiJmax,uiKmax,uiLmax;
|
unsigned int uiImax,uiJmax,uiKmax,uiLmax;
|
||||||
unsigned int uiIpos, uiJpos, uiKpos, uiLpos;
|
unsigned int uiIpos, uiJpos, uiKpos, uiLpos;
|
||||||
double *dGrid[4];
|
double *dGrid[4];
|
||||||
double dDeltaUnit;
|
double dDeltaUnit;
|
||||||
int iIshift, iJshift, iKshift;
|
int iIshift, iJshift, iKshift;
|
||||||
int iCellShift[3];
|
int iCellShift[3];
|
||||||
unsigned int i,j,k,l;
|
unsigned int i,j,k,l;
|
||||||
bool reflect;
|
bool reflect;
|
||||||
unsigned int uiTypeOffset;
|
unsigned int uiTypeOffset;
|
||||||
|
|
||||||
bool bPosSet;
|
bool bPosSet;
|
||||||
bool bDebug;
|
bool bDebug;
|
||||||
ErrorMsg *error;
|
ErrorMsg *error;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class deltaAdrOp
|
class deltaAdrOp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
deltaAdrOp(unsigned int max=0);
|
deltaAdrOp(unsigned int max=0);
|
||||||
virtual ~deltaAdrOp();
|
virtual ~deltaAdrOp();
|
||||||
void SetMax(unsigned int max);
|
void SetMax(unsigned int max);
|
||||||
unsigned int GetAdr(int pos);
|
unsigned int GetAdr(int pos);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
unsigned int uiMax;
|
unsigned int uiMax;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // ADROP_H
|
#endif // ADROP_H
|
||||||
|
@ -1,83 +1,83 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de)
|
* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de)
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "ErrorMsg.h"
|
#include "ErrorMsg.h"
|
||||||
|
|
||||||
ErrorMsg::ErrorMsg(unsigned int NoMessage)
|
ErrorMsg::ErrorMsg(unsigned int NoMessage)
|
||||||
{
|
{
|
||||||
NoMsg=NoMessage;
|
NoMsg=NoMessage;
|
||||||
if (NoMsg>0) Msg = new char*[NoMsg]; if (Msg==NULL) { fprintf(stderr,"Memory allocation failed!! exiting..."); exit(1); }
|
if (NoMsg>0) Msg = new char*[NoMsg]; if (Msg==NULL) { fprintf(stderr,"Memory allocation failed!! exiting..."); exit(1); }
|
||||||
for (unsigned int i=0;i<NoMsg;i++) Msg[i]=NULL;
|
for (unsigned int i=0;i<NoMsg;i++) Msg[i]=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorMsg::~ErrorMsg()
|
ErrorMsg::~ErrorMsg()
|
||||||
{
|
{
|
||||||
for (unsigned int i=0;i<NoMsg;i++) {delete[] Msg[i]; Msg[i]=NULL;};
|
for (unsigned int i=0;i<NoMsg;i++) {delete[] Msg[i]; Msg[i]=NULL;};
|
||||||
delete[] Msg; Msg=NULL;
|
delete[] Msg; Msg=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrorMsg::SetMsg(unsigned int nr, const char *Message)
|
void ErrorMsg::SetMsg(unsigned int nr, const char *Message)
|
||||||
{
|
{
|
||||||
if ((nr<1) || (nr>NoMsg) || (Message==NULL)) ownError();
|
if ((nr<1) || (nr>NoMsg) || (Message==NULL)) ownError();
|
||||||
Msg[nr-1] = new char[strlen(Message)+1]; if (Msg[nr-1]==NULL) { fprintf(stderr,"Memory allocation failed!! exiting..."); exit(1); }
|
Msg[nr-1] = new char[strlen(Message)+1]; if (Msg[nr-1]==NULL) { fprintf(stderr,"Memory allocation failed!! exiting..."); exit(1); }
|
||||||
Msg[nr-1]=strcpy(Msg[nr-1],Message);
|
Msg[nr-1]=strcpy(Msg[nr-1],Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrorMsg::Error(unsigned int nr,char *chAddMsg)
|
void ErrorMsg::Error(unsigned int nr,char *chAddMsg)
|
||||||
{
|
{
|
||||||
if ((nr>0) && (nr<=NoMsg))
|
if ((nr>0) && (nr<=NoMsg))
|
||||||
{
|
{
|
||||||
if (Msg[nr-1]!=NULL) fprintf(stderr,"%s",Msg[nr-1]);
|
if (Msg[nr-1]!=NULL) fprintf(stderr,"%s",Msg[nr-1]);
|
||||||
else fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr);
|
else fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr);
|
||||||
if (chAddMsg!=NULL) fprintf(stderr,"%s",chAddMsg);
|
if (chAddMsg!=NULL) fprintf(stderr,"%s",chAddMsg);
|
||||||
getchar();
|
getchar();
|
||||||
exit(nr);
|
exit(nr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr);
|
fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr);
|
||||||
getchar();
|
getchar();
|
||||||
exit(nr);
|
exit(nr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrorMsg::Error(unsigned int nr,int addNr)
|
void ErrorMsg::Error(unsigned int nr,int addNr)
|
||||||
{
|
{
|
||||||
if ((nr>0) && (nr<=NoMsg))
|
if ((nr>0) && (nr<=NoMsg))
|
||||||
{
|
{
|
||||||
if (Msg[nr-1]!=NULL) fprintf(stderr,"%s",Msg[nr-1]);
|
if (Msg[nr-1]!=NULL) fprintf(stderr,"%s",Msg[nr-1]);
|
||||||
else fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr);
|
else fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr);
|
||||||
fprintf(stderr,"%d",addNr);
|
fprintf(stderr,"%d",addNr);
|
||||||
getchar();
|
getchar();
|
||||||
exit(nr);
|
exit(nr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr);
|
fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr);
|
||||||
getchar();
|
getchar();
|
||||||
exit(nr);
|
exit(nr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrorMsg::ownError(void)
|
void ErrorMsg::ownError(void)
|
||||||
{
|
{
|
||||||
fprintf(stdout," Error occured by using Error Message class!! ... exiting...");
|
fprintf(stdout," Error occured by using Error Message class!! ... exiting...");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
100
tools/ErrorMsg.h
100
tools/ErrorMsg.h
@ -1,50 +1,50 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de)
|
* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de)
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class ErrorMsg
|
\class ErrorMsg
|
||||||
\author Thorsten Liebig
|
\author Thorsten Liebig
|
||||||
\version $Revision: 1.2 $
|
\version $Revision: 1.2 $
|
||||||
\date $Date: 2006/01/25 11:47:07 $
|
\date $Date: 2006/01/25 11:47:07 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _ERRORMSG_H_
|
#ifndef _ERRORMSG_H_
|
||||||
#define _ERRORMSG_H_
|
#define _ERRORMSG_H_
|
||||||
|
|
||||||
class ErrorMsg
|
class ErrorMsg
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///Constructor defines number of error messages
|
///Constructor defines number of error messages
|
||||||
ErrorMsg(unsigned int NoMessage=0);
|
ErrorMsg(unsigned int NoMessage=0);
|
||||||
///Deconstructor
|
///Deconstructor
|
||||||
virtual ~ErrorMsg();
|
virtual ~ErrorMsg();
|
||||||
///Methode for defining error messages
|
///Methode for defining error messages
|
||||||
/*! \param nr Number of defining error message \param *Message Set error message string \sa Error */
|
/*! \param nr Number of defining error message \param *Message Set error message string \sa Error */
|
||||||
void SetMsg(unsigned int nr, const char *Message);
|
void SetMsg(unsigned int nr, const char *Message);
|
||||||
///Call an error message. Will exit the program!
|
///Call an error message. Will exit the program!
|
||||||
/*! \param nr Number of called error message. default is 0 \sa SetMsg*/
|
/*! \param nr Number of called error message. default is 0 \sa SetMsg*/
|
||||||
void Error(unsigned int nr=0,char *chAddMsg=0);
|
void Error(unsigned int nr=0,char *chAddMsg=0);
|
||||||
|
|
||||||
void Error(unsigned int nr,int addNr);
|
void Error(unsigned int nr,int addNr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ownError(void);
|
void ownError(void);
|
||||||
unsigned int NoMsg;
|
unsigned int NoMsg;
|
||||||
char **Msg;
|
char **Msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //_ERRORMSG_H_
|
#endif //_ERRORMSG_H_
|
||||||
|
@ -1,141 +1,141 @@
|
|||||||
#include "ExpenseLog.h"
|
#include "ExpenseLog.h"
|
||||||
|
|
||||||
ExpenseModule::ExpenseModule(const char* moduleName)
|
ExpenseModule::ExpenseModule(const char* moduleName)
|
||||||
{
|
{
|
||||||
chModuleName=moduleName;
|
chModuleName=moduleName;
|
||||||
uiDoubleAdditions=uiDoubleMultiplications=uiIntAdditions=uiIntMultiplications=uiAssignments=uiBoolOp=0;
|
uiDoubleAdditions=uiDoubleMultiplications=uiIntAdditions=uiIntMultiplications=uiAssignments=uiBoolOp=0;
|
||||||
uiMrdDA=uiMrdDM=uiMrdIA=uiMrdIM=uiMrdAssign=uiMrdBO=0;
|
uiMrdDA=uiMrdDM=uiMrdIA=uiMrdIM=uiMrdAssign=uiMrdBO=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpenseModule::~ExpenseModule() {};
|
ExpenseModule::~ExpenseModule() {};
|
||||||
|
|
||||||
void ExpenseModule::Clear()
|
void ExpenseModule::Clear()
|
||||||
{
|
{
|
||||||
uiDoubleAdditions=uiDoubleMultiplications=uiIntAdditions=uiIntMultiplications=uiAssignments=uiBoolOp=0;
|
uiDoubleAdditions=uiDoubleMultiplications=uiIntAdditions=uiIntMultiplications=uiAssignments=uiBoolOp=0;
|
||||||
uiMrdDA=uiMrdDM=uiMrdIA=uiMrdIM=uiMrdAssign=uiMrdBO=0;
|
uiMrdDA=uiMrdDM=uiMrdIA=uiMrdIM=uiMrdAssign=uiMrdBO=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpenseModule::AddDoubleAdditons(unsigned int number)
|
void ExpenseModule::AddDoubleAdditons(unsigned int number)
|
||||||
{
|
{
|
||||||
uiDoubleAdditions+=number;
|
uiDoubleAdditions+=number;
|
||||||
if (uiDoubleAdditions>=MRD)
|
if (uiDoubleAdditions>=MRD)
|
||||||
{
|
{
|
||||||
uiDoubleAdditions-=MRD;
|
uiDoubleAdditions-=MRD;
|
||||||
++uiMrdDA;
|
++uiMrdDA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpenseModule::AddDoubleMultiplications(unsigned int number)
|
void ExpenseModule::AddDoubleMultiplications(unsigned int number)
|
||||||
{
|
{
|
||||||
uiDoubleMultiplications+=number;
|
uiDoubleMultiplications+=number;
|
||||||
if (uiDoubleMultiplications>=MRD)
|
if (uiDoubleMultiplications>=MRD)
|
||||||
{
|
{
|
||||||
uiDoubleMultiplications-=MRD;
|
uiDoubleMultiplications-=MRD;
|
||||||
++uiMrdDM;
|
++uiMrdDM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpenseModule::AddIntAdditons(unsigned int number)
|
void ExpenseModule::AddIntAdditons(unsigned int number)
|
||||||
{
|
{
|
||||||
uiIntAdditions+=number;
|
uiIntAdditions+=number;
|
||||||
if (uiIntAdditions>=MRD)
|
if (uiIntAdditions>=MRD)
|
||||||
{
|
{
|
||||||
uiIntAdditions-=MRD;
|
uiIntAdditions-=MRD;
|
||||||
++uiMrdIA;
|
++uiMrdIA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpenseModule::AddIntMultiplications(unsigned int number)
|
void ExpenseModule::AddIntMultiplications(unsigned int number)
|
||||||
{
|
{
|
||||||
uiIntMultiplications+=number;
|
uiIntMultiplications+=number;
|
||||||
if (uiIntMultiplications>=MRD)
|
if (uiIntMultiplications>=MRD)
|
||||||
{
|
{
|
||||||
uiIntMultiplications-=MRD;
|
uiIntMultiplications-=MRD;
|
||||||
++uiMrdIM;
|
++uiMrdIM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpenseModule::AddAssignments(unsigned int number)
|
void ExpenseModule::AddAssignments(unsigned int number)
|
||||||
{
|
{
|
||||||
uiAssignments+=number;
|
uiAssignments+=number;
|
||||||
if (uiAssignments>=MRD)
|
if (uiAssignments>=MRD)
|
||||||
{
|
{
|
||||||
uiAssignments-=MRD;
|
uiAssignments-=MRD;
|
||||||
++uiMrdAssign;
|
++uiMrdAssign;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpenseModule::AddBoolOperations(unsigned int number)
|
void ExpenseModule::AddBoolOperations(unsigned int number)
|
||||||
{
|
{
|
||||||
uiBoolOp+=number;
|
uiBoolOp+=number;
|
||||||
if (uiBoolOp>=MRD)
|
if (uiBoolOp>=MRD)
|
||||||
{
|
{
|
||||||
uiBoolOp-=MRD;
|
uiBoolOp-=MRD;
|
||||||
++uiMrdBO;
|
++uiMrdBO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpenseModule::AddOperations(unsigned int IntAdd, unsigned int IntMul, unsigned int DoubleAdd, unsigned int DoubleMul, unsigned int Assigns, unsigned int BoolOp)
|
void ExpenseModule::AddOperations(unsigned int IntAdd, unsigned int IntMul, unsigned int DoubleAdd, unsigned int DoubleMul, unsigned int Assigns, unsigned int BoolOp)
|
||||||
{
|
{
|
||||||
this->AddIntAdditons(IntAdd);
|
this->AddIntAdditons(IntAdd);
|
||||||
this->AddIntMultiplications(IntMul);
|
this->AddIntMultiplications(IntMul);
|
||||||
this->AddDoubleAdditons(DoubleAdd);
|
this->AddDoubleAdditons(DoubleAdd);
|
||||||
this->AddDoubleMultiplications(DoubleMul);
|
this->AddDoubleMultiplications(DoubleMul);
|
||||||
this->AddAssignments(Assigns);
|
this->AddAssignments(Assigns);
|
||||||
this->AddBoolOperations(BoolOp);
|
this->AddBoolOperations(BoolOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpenseModule::PrintfSelf(FILE* file)
|
void ExpenseModule::PrintfSelf(FILE* file)
|
||||||
{
|
{
|
||||||
fprintf(file,"\n***********\n Module: %s\n Additions:\n Double: %3.0d%9d\tInteger: %3.0d%9d",chModuleName,uiMrdDA,uiDoubleAdditions,uiMrdIA,uiIntAdditions);
|
fprintf(file,"\n***********\n Module: %s\n Additions:\n Double: %3.0d%9d\tInteger: %3.0d%9d",chModuleName,uiMrdDA,uiDoubleAdditions,uiMrdIA,uiIntAdditions);
|
||||||
fprintf(file,"\n\n Multiplications:\n Double: %3.0d%9d\tInteger: %3.0d%9d\n",uiMrdDM,uiDoubleMultiplications,uiMrdIM,uiIntMultiplications);
|
fprintf(file,"\n\n Multiplications:\n Double: %3.0d%9d\tInteger: %3.0d%9d\n",uiMrdDM,uiDoubleMultiplications,uiMrdIM,uiIntMultiplications);
|
||||||
fprintf(file,"\n Assignments: %3.0d%9d\tBool Operations: %3.0d%9d\n",uiMrdAssign,uiAssignments,uiMrdBO,uiBoolOp);
|
fprintf(file,"\n Assignments: %3.0d%9d\tBool Operations: %3.0d%9d\n",uiMrdAssign,uiAssignments,uiMrdBO,uiBoolOp);
|
||||||
fprintf(file,"\n***********\n");
|
fprintf(file,"\n***********\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************************************************************/
|
/***********************************************************************************************************************/
|
||||||
|
|
||||||
ExpenseLog::ExpenseLog(void)
|
ExpenseLog::ExpenseLog(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpenseLog::~ExpenseLog(void)
|
ExpenseLog::~ExpenseLog(void)
|
||||||
{
|
{
|
||||||
for (size_t i=0;i<vModules.size();++i) {delete vModules.at(i); vModules.at(i)=NULL;}
|
for (size_t i=0;i<vModules.size();++i) {delete vModules.at(i); vModules.at(i)=NULL;}
|
||||||
vModules.clear();
|
vModules.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpenseModule* ExpenseLog::AddModule(const char* name)
|
ExpenseModule* ExpenseLog::AddModule(const char* name)
|
||||||
{
|
{
|
||||||
ExpenseModule* newModule = new ExpenseModule(name);
|
ExpenseModule* newModule = new ExpenseModule(name);
|
||||||
vModules.push_back(newModule);
|
vModules.push_back(newModule);
|
||||||
return newModule;
|
return newModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpenseLog::PrintAll(FILE *file)
|
void ExpenseLog::PrintAll(FILE *file)
|
||||||
{
|
{
|
||||||
double totalAdd=0,totalMul=0,totalBool=0,totalAssign=0;
|
double totalAdd=0,totalMul=0,totalBool=0,totalAssign=0;
|
||||||
fprintf(stderr,"\n ----------------\n Expense Log PrintOut\n Nr of Modules: %d\n",vModules.size());
|
fprintf(stderr,"\n ----------------\n Expense Log PrintOut\n Nr of Modules: %d\n",vModules.size());
|
||||||
for (size_t i=0;i<vModules.size();++i)
|
for (size_t i=0;i<vModules.size();++i)
|
||||||
{
|
{
|
||||||
totalAdd+=((double)vModules.at(i)->uiIntAdditions+(double)vModules.at(i)->uiDoubleAdditions) + 1e9*((double)vModules.at(i)->uiMrdIA+(double)vModules.at(i)->uiMrdIA);
|
totalAdd+=((double)vModules.at(i)->uiIntAdditions+(double)vModules.at(i)->uiDoubleAdditions) + 1e9*((double)vModules.at(i)->uiMrdIA+(double)vModules.at(i)->uiMrdIA);
|
||||||
totalMul+=((double)vModules.at(i)->uiIntMultiplications+(double)vModules.at(i)->uiDoubleMultiplications) + 1e9*(double)(vModules.at(i)->uiMrdIM+vModules.at(i)->uiMrdIM);
|
totalMul+=((double)vModules.at(i)->uiIntMultiplications+(double)vModules.at(i)->uiDoubleMultiplications) + 1e9*(double)(vModules.at(i)->uiMrdIM+vModules.at(i)->uiMrdIM);
|
||||||
totalBool+=(double)vModules.at(i)->uiBoolOp + 1e9*(double)vModules.at(i)->uiMrdBO;
|
totalBool+=(double)vModules.at(i)->uiBoolOp + 1e9*(double)vModules.at(i)->uiMrdBO;
|
||||||
totalAssign+=(double)vModules.at(i)->uiAssignments + 1e9*(double)vModules.at(i)->uiMrdAssign;
|
totalAssign+=(double)vModules.at(i)->uiAssignments + 1e9*(double)vModules.at(i)->uiMrdAssign;
|
||||||
vModules.at(i)->PrintfSelf(file);
|
vModules.at(i)->PrintfSelf(file);
|
||||||
}
|
}
|
||||||
fprintf(stderr," Total:\n Additions: %e Multiplications: %e\n Bool Operations: %e Assignments: %e\n",totalAdd,totalMul,totalBool,totalAssign);
|
fprintf(stderr," Total:\n Additions: %e Multiplications: %e\n Bool Operations: %e Assignments: %e\n",totalAdd,totalMul,totalBool,totalAssign);
|
||||||
fprintf(stderr,"\n ----------------\n");
|
fprintf(stderr,"\n ----------------\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpenseLog::ClearAll()
|
void ExpenseLog::ClearAll()
|
||||||
{
|
{
|
||||||
for (size_t i=0;i<vModules.size();++i)
|
for (size_t i=0;i<vModules.size();++i)
|
||||||
{
|
{
|
||||||
vModules.at(i)->Clear();
|
vModules.at(i)->Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,92 +1,92 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define EXPENSE_LOG 0
|
#define EXPENSE_LOG 0
|
||||||
#define MRD 1000000000
|
#define MRD 1000000000
|
||||||
|
|
||||||
#if EXPENSE_LOG==1
|
#if EXPENSE_LOG==1
|
||||||
|
|
||||||
#define EXPENSE_DEFINE \
|
#define EXPENSE_DEFINE \
|
||||||
ExpenseLog EL; \
|
ExpenseLog EL; \
|
||||||
ExpenseModule* EngineExpense=EL.AddModule("Static Engine Expenses"); \
|
ExpenseModule* EngineExpense=EL.AddModule("Static Engine Expenses"); \
|
||||||
ExpenseModule* PPExpense=EL.AddModule("Static Post Processing"); \
|
ExpenseModule* PPExpense=EL.AddModule("Static Post Processing"); \
|
||||||
ExpenseModule* AdrOpExpense=EL.AddModule("Adress Operator");
|
ExpenseModule* AdrOpExpense=EL.AddModule("Adress Operator");
|
||||||
#define EXTERN_EXPENSE_DEFINE extern ExpenseLog EL;
|
#define EXTERN_EXPENSE_DEFINE extern ExpenseLog EL;
|
||||||
#define ENGINEEXPENSE_DEFINE extern ExpenseModule* EngineExpense;
|
#define ENGINEEXPENSE_DEFINE extern ExpenseModule* EngineExpense;
|
||||||
#define POSTPROCEXPENSE_DEFINE extern ExpenseModule* PPExpense;
|
#define POSTPROCEXPENSE_DEFINE extern ExpenseModule* PPExpense;
|
||||||
#define ADREXPENSE_DEFINE extern ExpenseModule* AdrOpExpense;
|
#define ADREXPENSE_DEFINE extern ExpenseModule* AdrOpExpense;
|
||||||
#define ENGINEEXPENSE(IA,IM,DA,DM,AS,BO) EngineExpense->AddOperations((IA),(IM),(DA),(DM),(AS),(BO));
|
#define ENGINEEXPENSE(IA,IM,DA,DM,AS,BO) EngineExpense->AddOperations((IA),(IM),(DA),(DM),(AS),(BO));
|
||||||
#define POSTPROCEXPENSE(IA,IM,DA,DM,AS,BO) PPExpense->AddOperations((IA),(IM),(DA),(DM),(AS),(BO));
|
#define POSTPROCEXPENSE(IA,IM,DA,DM,AS,BO) PPExpense->AddOperations((IA),(IM),(DA),(DM),(AS),(BO));
|
||||||
#define ADRESSEXPENSE(IA,IM,DA,DM,AS,BO) AdrOpExpense->AddOperations((IA),(IM),(DA),(DM),(AS),(BO));
|
#define ADRESSEXPENSE(IA,IM,DA,DM,AS,BO) AdrOpExpense->AddOperations((IA),(IM),(DA),(DM),(AS),(BO));
|
||||||
#define EXPENSEPRINT EL.PrintAll(stderr);
|
#define EXPENSEPRINT EL.PrintAll(stderr);
|
||||||
#define EXPENSECLEAR EL.ClearAll();
|
#define EXPENSECLEAR EL.ClearAll();
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define EXPENSE_DEFINE
|
#define EXPENSE_DEFINE
|
||||||
#define EXTERN_EXPENSE_DEFINE
|
#define EXTERN_EXPENSE_DEFINE
|
||||||
#define ENGINEEXPENSE_DEFINE
|
#define ENGINEEXPENSE_DEFINE
|
||||||
#define POSTPROCEXPENSE_DEFINE
|
#define POSTPROCEXPENSE_DEFINE
|
||||||
#define ADREXPENSE_DEFINE
|
#define ADREXPENSE_DEFINE
|
||||||
#define ENGINEEXPENSE(IA,IM,DA,DM,AS,BO)
|
#define ENGINEEXPENSE(IA,IM,DA,DM,AS,BO)
|
||||||
#define POSTPROCEXPENSE(IA,IM,DA,DM,AS,BO)
|
#define POSTPROCEXPENSE(IA,IM,DA,DM,AS,BO)
|
||||||
#define ADRESSEXPENSE(IA,IM,DA,DM,AS,BO)
|
#define ADRESSEXPENSE(IA,IM,DA,DM,AS,BO)
|
||||||
#define EXPENSEPRINT
|
#define EXPENSEPRINT
|
||||||
#define EXPENSECLEAR
|
#define EXPENSECLEAR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class ExpenseModule
|
class ExpenseModule
|
||||||
{
|
{
|
||||||
friend class ExpenseLog;
|
friend class ExpenseLog;
|
||||||
public:
|
public:
|
||||||
ExpenseModule(const char* moduleName);
|
ExpenseModule(const char* moduleName);
|
||||||
~ExpenseModule();
|
~ExpenseModule();
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
void AddDoubleAdditons(unsigned int number);
|
void AddDoubleAdditons(unsigned int number);
|
||||||
void AddDoubleMultiplications(unsigned int number);
|
void AddDoubleMultiplications(unsigned int number);
|
||||||
|
|
||||||
void AddIntAdditons(unsigned int number);
|
void AddIntAdditons(unsigned int number);
|
||||||
void AddIntMultiplications(unsigned int number);
|
void AddIntMultiplications(unsigned int number);
|
||||||
|
|
||||||
void AddAssignments(unsigned int number);
|
void AddAssignments(unsigned int number);
|
||||||
void AddBoolOperations(unsigned int number);
|
void AddBoolOperations(unsigned int number);
|
||||||
|
|
||||||
void AddOperations(unsigned int IntAdd, unsigned int IntMul, unsigned int DoubleAdd, unsigned int DoubleMul, unsigned int Assigns, unsigned int BoolOp);
|
void AddOperations(unsigned int IntAdd, unsigned int IntMul, unsigned int DoubleAdd, unsigned int DoubleMul, unsigned int Assigns, unsigned int BoolOp);
|
||||||
|
|
||||||
void PrintfSelf(FILE* file=stdout);
|
void PrintfSelf(FILE* file=stdout);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const char* chModuleName;
|
const char* chModuleName;
|
||||||
unsigned int uiDoubleAdditions;
|
unsigned int uiDoubleAdditions;
|
||||||
unsigned int uiDoubleMultiplications;
|
unsigned int uiDoubleMultiplications;
|
||||||
unsigned int uiIntAdditions;
|
unsigned int uiIntAdditions;
|
||||||
unsigned int uiIntMultiplications;
|
unsigned int uiIntMultiplications;
|
||||||
unsigned int uiAssignments;
|
unsigned int uiAssignments;
|
||||||
unsigned int uiBoolOp;
|
unsigned int uiBoolOp;
|
||||||
unsigned int uiMrdDA;
|
unsigned int uiMrdDA;
|
||||||
unsigned int uiMrdDM;
|
unsigned int uiMrdDM;
|
||||||
unsigned int uiMrdIA;
|
unsigned int uiMrdIA;
|
||||||
unsigned int uiMrdIM;
|
unsigned int uiMrdIM;
|
||||||
unsigned int uiMrdAssign;
|
unsigned int uiMrdAssign;
|
||||||
unsigned int uiMrdBO;
|
unsigned int uiMrdBO;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExpenseLog
|
class ExpenseLog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ExpenseLog(void);
|
ExpenseLog(void);
|
||||||
~ExpenseLog(void);
|
~ExpenseLog(void);
|
||||||
|
|
||||||
ExpenseModule* AddModule(const char* name);
|
ExpenseModule* AddModule(const char* name);
|
||||||
void PrintAll(FILE *file=stdout);
|
void PrintAll(FILE *file=stdout);
|
||||||
void ClearAll();
|
void ClearAll();
|
||||||
protected:
|
protected:
|
||||||
vector<ExpenseModule*> vModules;
|
vector<ExpenseModule*> vModules;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user