diff --git a/mex/sources/kalman/sylv/cc/SylvException.cpp b/mex/sources/kalman/sylv/cc/SylvException.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5d5826f8859c46c07be8db8a8e74ec9db75d1d18 --- /dev/null +++ b/mex/sources/kalman/sylv/cc/SylvException.cpp @@ -0,0 +1,69 @@ +/* $Header: /var/lib/cvs/dynare_cpp/sylv/cc/SylvException.cpp,v 1.2 2004/10/01 10:30:40 kamenik Exp $ */ + +/* Tag $Name: $ */ + +#include "SylvException.h" + +#include <string.h> +#include <stdio.h> + +SylvException::SylvException(const char* f, int l, const SylvException* s) +{ + strcpy(file,f); + line = l; + source = s; +} + +SylvException::~SylvException() +{ + if (source != NULL) { + delete source; + } +} + +void SylvException::printMessage() const +{ + char mes[1500]; + mes[0] = '\0'; + printMessage(mes, 1499); + printf(mes); +} + +int SylvException::printMessage(char* str, int maxlen) const +{ + int remain = maxlen; + if (source != NULL) { + remain = source->printMessage(str, maxlen); + } + char aux[100]; + sprintf(aux, "From %s:%d\n", file, line); + int newremain = remain - strlen(aux); + if (newremain < 0) { + aux[remain] = '\0'; + newremain = 0; + } + strcat(str, aux); + return newremain; +} + +SylvExceptionMessage::SylvExceptionMessage(const char* f, int i, + const char* mes) + : SylvException(f,i,NULL) +{ + strcpy(message,mes); +} + +int SylvExceptionMessage::printMessage(char* str, int maxlen) const +{ + char aux[600]; + sprintf(aux, "At %s:%d:%s\n", file, line, message); + int newremain = maxlen - strlen(aux); + if (newremain < 0) { + aux[maxlen] = '\0'; + newremain = 0; + } + strcat(str, aux); + return newremain; +} + + diff --git a/mex/sources/kalman/sylv/cc/SylvMemory.h b/mex/sources/kalman/sylv/cc/SylvMemory.h new file mode 100644 index 0000000000000000000000000000000000000000..9f89c06cd7ee4e26ff638a71762c60c46f1339ac --- /dev/null +++ b/mex/sources/kalman/sylv/cc/SylvMemory.h @@ -0,0 +1,63 @@ +/* $Header: /var/lib/cvs/dynare_cpp/sylv/cc/SylvMemory.h,v 1.1.1.1 2004/06/04 13:00:49 kamenik Exp $ */ + +/* Tag $Name: $ */ + +#ifndef SYLV_MEMORY_H +#define SYLV_MEMORY_H + +//#include "SylvParams.h" + +#include <new> + +class MallocAllocator { +#ifdef USE_MEMORY_POOL +public: + void* operator new(size_t size); + void* operator new[](size_t size); + void operator delete(void* p); + void operator delete[](void* p); +#endif +}; +/* +#ifdef USE_MEMORY_POOL +void* operator new(size_t size); +void* operator new[](size_t size); +void operator delete(void* p); +void operator delete[](void* p); +#endif + +class SylvMemoryPool { + char* base; + size_t length; + size_t allocated; + bool stack_mode; + SylvMemoryPool(const SylvMemoryPool&); + const SylvMemoryPool& operator=(const SylvMemoryPool&); +public: + SylvMemoryPool(); + ~SylvMemoryPool(); + void init(size_t size); + void* allocate(size_t size); + void free(void* p); + void reset(); + void setStackMode(bool); +}; + +class SylvMemoryDriver { + SylvMemoryDriver(const SylvMemoryDriver&); + const SylvMemoryDriver& operator=(const SylvMemoryDriver&); +public: + SylvMemoryDriver(int num_d, int m, int n, int order); + SylvMemoryDriver(const SylvParams& pars, int num_d, int m, int n, int order); + static void setStackMode(bool); + ~SylvMemoryDriver(); +protected: + void allocate(int num_d, int m, int n, int order); +}; +*/ +#endif /* SYLV_MEMORY_H */ + + +// Local Variables: +// mode:C++ +// End: