HeapFactory.h
Go to the documentation of this file.00001
00002
00003 #ifndef HEAP_FACTORY_H_
00004 #define HEAP_FACTORY_H_
00005
00006 #include <fesa-core/DataStore/DeviceFactoryImp.h>
00007 #include <fesa-core/Exception/FesaException.h>
00008
00009 #include <cstring>
00010
00011 namespace fesa
00012 {
00013
00014 template<typename GlobalDeviceType, typename DomainStoreType, typename DevInstType> class DeviceFactoryImp;
00015
00024 template<typename GlobalDeviceType, typename DomainStoreType, typename DevInstType>
00025 class HeapFactory: public DeviceFactoryImp<GlobalDeviceType, DomainStoreType, DevInstType>
00026 {
00027 public:
00032 HeapFactory(const std::string& className);
00033
00039 bool setUpMemory();
00040 };
00041
00042
00043
00044
00045 template<typename GlobalDeviceType, typename DomainStoreType, typename DevInstType>
00046 HeapFactory<GlobalDeviceType, DomainStoreType, DevInstType>::HeapFactory(const std::string& className) :
00047 DeviceFactoryImp<GlobalDeviceType, DomainStoreType, DevInstType> (className)
00048 {
00049 }
00050
00051 template<typename GlobalDeviceType, typename DomainStoreType, typename DevInstType>
00052 bool HeapFactory<GlobalDeviceType, DomainStoreType, DevInstType>::setUpMemory()
00053 {
00054 char* p;
00055
00056
00057 this->computeMemorySize();
00058 try
00059 {
00060
00061 p = new char[this->size_];
00062 }
00063 catch (std::bad_alloc& ex)
00064 {
00065 throw FesaException(__FILE__, __LINE__, FesaErrorAllocatingMemory.c_str(), ex.what());
00066 }
00067
00068
00069 std::memset(p, 0, this->size_);
00070
00071
00072 this->mapFields(p, true);
00073 return true;
00074 }
00075
00076 }
00077
00078 #endif // HEAP_FACTORY_H_