Merge branch 'master' of file:///home/guilhem/Dropbox/gitRoot/CosmoToolbox
This commit is contained in:
commit
e8d1edf453
@ -1,6 +1,7 @@
|
||||
#ifndef __COSMOTOOL_CONFIG_HPP
|
||||
#define __COSMOTOOL_CONFIG_HPP
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <exception>
|
||||
#include <cstring>
|
||||
@ -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() {}
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -142,10 +142,10 @@ public:
|
||||
namespace CosmoTool {
|
||||
template<typename T>
|
||||
ProgressiveOutput<T>
|
||||
ProgressiveOutput<T>::saveArrayProgressive(const char *fname, uint32_t *dimList,
|
||||
ProgressiveOutput<T>::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<typename T>
|
||||
ProgressiveInput<T>
|
||||
ProgressiveInput<T>::loadArrayProgressive(const char *fname, uint32_t *&dimList,
|
||||
ProgressiveInput<T>::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<typename T>
|
||||
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<typename T>
|
||||
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<float>;
|
||||
template class ProgressiveOutput<double>;
|
||||
|
||||
template void loadArray<int>(const char *fname,
|
||||
template void loadArray<int>(const std::string& fname,
|
||||
int*& array, uint32_t *&dimList, uint32_t& rank);
|
||||
template void loadArray<float>(const char *fname,
|
||||
template void loadArray<float>(const std::string& fname,
|
||||
float*& array, uint32_t *&dimList, uint32_t& rank);
|
||||
template void loadArray<double>(const char *fname,
|
||||
template void loadArray<double>(const std::string& fname,
|
||||
double*& array, uint32_t *&dimList, uint32_t& rank);
|
||||
|
||||
template void saveArray<int>(const char *fname,
|
||||
template void saveArray<int>(const std::string& fname,
|
||||
int *array, uint32_t *dimList, uint32_t rank);
|
||||
template void saveArray<float>(const char *fname,
|
||||
template void saveArray<float>(const std::string& fname,
|
||||
float *array, uint32_t *dimList, uint32_t rank);
|
||||
template void saveArray<double>(const char *fname,
|
||||
template void saveArray<double>(const std::string& fname,
|
||||
double *array, uint32_t *dimList, uint32_t rank);
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "config.hpp"
|
||||
#include <stdint.h>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace CosmoTool
|
||||
@ -77,7 +78,7 @@ namespace CosmoTool
|
||||
|
||||
public:
|
||||
static ProgressiveInput<T>
|
||||
loadArrayProgressive(const char *fname, uint32_t *&dimList,
|
||||
loadArrayProgressive(const std::string& fname, uint32_t *&dimList,
|
||||
uint32_t& rank);
|
||||
|
||||
ProgressiveInput() {
|
||||
@ -143,7 +144,7 @@ namespace CosmoTool
|
||||
|
||||
public:
|
||||
static ProgressiveOutput<T>
|
||||
saveArrayProgressive(const char *fname, uint32_t *dimList,
|
||||
saveArrayProgressive(const std::string& fname, uint32_t *dimList,
|
||||
uint32_t rank);
|
||||
|
||||
ProgressiveOutput() {
|
||||
@ -181,11 +182,11 @@ namespace CosmoTool
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void saveArray(const char *fname,
|
||||
void saveArray(const std::string& fname,
|
||||
T *array, uint32_t *dimList, uint32_t rank);
|
||||
|
||||
template<typename T>
|
||||
void loadArray(const char *fname,
|
||||
void loadArray(const std::string& fname,
|
||||
T*& array, uint32_t *& dimList, uint32_t& rank)
|
||||
throw (NoSuchFileException);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user