diff --git a/src/config.hpp b/src/config.hpp index 28f8bcd..b046e2f 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -1,6 +1,7 @@ #ifndef __COSMOTOOL_CONFIG_HPP #define __COSMOTOOL_CONFIG_HPP +#include #include #include #include @@ -50,14 +51,19 @@ namespace CosmoTool class Exception : public std::exception { public: - Exception(const char *mess = 0) - : msg(mess) {} + Exception(const std::string& mess) + : msg(mess), msgok(true) {} + Exception() + : msgok(false) {} - const char *getMessage() const { return msg != 0 ? msg : "No message"; }; - virtual const char *what() const throw () { return msg != 0 ? msg : "What 'what' ?"; }; + virtual ~Exception() throw () {} + + const char *getMessage() const { return msgok ? msg.c_str() : "No message"; }; + virtual const char *what() const throw () { return msgok ? msg.c_str() : "What 'what' ?"; }; private: - const char *msg; + std::string msg; + bool msgok; }; /** @@ -67,8 +73,10 @@ namespace CosmoTool class InvalidArgumentException : public Exception { public: - InvalidArgumentException(const char *mess = 0) + InvalidArgumentException(const std::string& mess) : Exception(mess) {} + InvalidArgumentException() + : Exception() {} }; /** @@ -76,8 +84,10 @@ namespace CosmoTool class InvalidRangeException : public Exception { public: - InvalidRangeException(const char *mess = 0) + InvalidRangeException(const std::string& mess) : Exception(mess) {} + InvalidRangeException() + : Exception() {} }; /** @@ -85,8 +95,10 @@ namespace CosmoTool class NoSuchFileException : public Exception { public: - NoSuchFileException(const char *mess = 0) + NoSuchFileException(const std::string& mess) : Exception(mess) {} + NoSuchFileException() + : Exception() {} }; /** @@ -94,22 +106,28 @@ namespace CosmoTool class InvalidFileFormatException : public Exception { public: - InvalidFileFormatException(const char *mess = 0) + InvalidFileFormatException(const std::string& mess) : Exception(mess) {} + InvalidFileFormatException() + : Exception() {} }; class EndOfFileException: public Exception { public: - EndOfFileException(const char *mess = 0) + EndOfFileException(const std::string& mess) : Exception(mess) {} + EndOfFileException() + : Exception() {} }; class FilesystemFullException: public Exception { public: - FilesystemFullException(const char *mess = 0) + FilesystemFullException(const std::string& mess) : Exception(mess) {} + FilesystemFullException() + : Exception() {} }; }; diff --git a/src/powerSpectrum.cpp b/src/powerSpectrum.cpp index 6ad7c89..9f3d7c8 100644 --- a/src/powerSpectrum.cpp +++ b/src/powerSpectrum.cpp @@ -21,7 +21,7 @@ using namespace std; #define POWER_BDM 7 #define POWER_TEST 8 -#define POWER_SPECTRUM POWER_EFSTATHIOU +#define POWER_SPECTRUM HU_WIGGLES namespace Cosmology { diff --git a/src/yorick.cpp b/src/yorick.cpp index 65ed7c5..ac8556a 100644 --- a/src/yorick.cpp +++ b/src/yorick.cpp @@ -142,10 +142,10 @@ public: namespace CosmoTool { template ProgressiveOutput - ProgressiveOutput::saveArrayProgressive(const char *fname, uint32_t *dimList, + ProgressiveOutput::saveArrayProgressive(const std::string& fname, uint32_t *dimList, uint32_t rank) { - NcFile *f = new NcFile(fname, NcFile::Replace); + NcFile *f = new NcFile(fname.c_str(), NcFile::Replace); assert(f->is_valid()); @@ -171,10 +171,10 @@ namespace CosmoTool { template ProgressiveInput - ProgressiveInput::loadArrayProgressive(const char *fname, uint32_t *&dimList, + ProgressiveInput::loadArrayProgressive(const std::string& fname, uint32_t *&dimList, uint32_t& rank) { - NcFile *f = new NcFile(fname, NcFile::ReadOnly); + NcFile *f = new NcFile(fname.c_str(), NcFile::ReadOnly); assert(f->is_valid()); @@ -193,10 +193,10 @@ namespace CosmoTool { } template - void saveArray(const char *fname, + void saveArray(const std::string& fname, T *array, uint32_t *dimList, uint32_t rank) { - NcFile f(fname, NcFile::Replace); + NcFile f(fname.c_str(), NcFile::Replace); assert(f.is_valid()); @@ -217,11 +217,11 @@ namespace CosmoTool { } template - void loadArray(const char *fname, + void loadArray(const std::string& fname, T*&array, uint32_t *&dimList, uint32_t& rank) throw (NoSuchFileException) { - NcFile f(fname, NcFile::ReadOnly); + NcFile f(fname.c_str(), NcFile::ReadOnly); if (!f.is_valid()) throw NoSuchFileException(fname); @@ -251,18 +251,18 @@ namespace CosmoTool { template class ProgressiveOutput; template class ProgressiveOutput; - template void loadArray(const char *fname, + template void loadArray(const std::string& fname, int*& array, uint32_t *&dimList, uint32_t& rank); - template void loadArray(const char *fname, + template void loadArray(const std::string& fname, float*& array, uint32_t *&dimList, uint32_t& rank); - template void loadArray(const char *fname, + template void loadArray(const std::string& fname, double*& array, uint32_t *&dimList, uint32_t& rank); - template void saveArray(const char *fname, + template void saveArray(const std::string& fname, int *array, uint32_t *dimList, uint32_t rank); - template void saveArray(const char *fname, + template void saveArray(const std::string& fname, float *array, uint32_t *dimList, uint32_t rank); - template void saveArray(const char *fname, + template void saveArray(const std::string& fname, double *array, uint32_t *dimList, uint32_t rank); } diff --git a/src/yorick.hpp b/src/yorick.hpp index f124ae8..25734f7 100644 --- a/src/yorick.hpp +++ b/src/yorick.hpp @@ -4,6 +4,7 @@ #include "config.hpp" #include #include +#include namespace CosmoTool @@ -77,8 +78,8 @@ namespace CosmoTool public: static ProgressiveInput - loadArrayProgressive(const char *fname, uint32_t *&dimList, - uint32_t& rank); + loadArrayProgressive(const std::string& fname, uint32_t *&dimList, + uint32_t& rank); ProgressiveInput() { impl = 0; @@ -143,8 +144,8 @@ namespace CosmoTool public: static ProgressiveOutput - saveArrayProgressive(const char *fname, uint32_t *dimList, - uint32_t rank); + saveArrayProgressive(const std::string& fname, uint32_t *dimList, + uint32_t rank); ProgressiveOutput() { impl = 0; @@ -181,11 +182,11 @@ namespace CosmoTool }; template - void saveArray(const char *fname, + void saveArray(const std::string& fname, T *array, uint32_t *dimList, uint32_t rank); template - void loadArray(const char *fname, + void loadArray(const std::string& fname, T*& array, uint32_t *& dimList, uint32_t& rank) throw (NoSuchFileException);