reformat SharedMemoryFactory according to code guidelines

This commit is contained in:
Dennis Luxen 2014-06-11 15:22:51 +02:00
parent 096f187d6f
commit ed01eeaeb3

View File

@ -204,6 +204,7 @@ class SharedMemory : boost::noncopyable
private:
char *m_shmid;
bool m_initialized;
public:
void SetID(char *shmid)
{
@ -217,8 +218,7 @@ class SharedMemory : boost::noncopyable
{
if (m_initialized)
{
SimpleLogger().Write(logDEBUG) <<
"automatic memory deallocation";
SimpleLogger().Write(logDEBUG) << "automatic memory deallocation";
if (!boost::interprocess::shared_memory_object::remove(m_shmid))
{
SimpleLogger().Write(logDEBUG) << "could not deallocate id " << m_shmid;
@ -228,13 +228,9 @@ class SharedMemory : boost::noncopyable
};
public:
void * Ptr() const
{
return region.get_address();
}
void *Ptr() const { return region.get_address(); }
SharedMemory(
const boost::filesystem::path & lock_file,
SharedMemory(const boost::filesystem::path &lock_file,
const int id,
const uint64_t size = 0,
bool read_write = false,
@ -249,7 +245,8 @@ class SharedMemory : boost::noncopyable
read_write ? boost::interprocess::read_write : boost::interprocess::read_only);
region = boost::interprocess::mapped_region(
shm, read_write ? boost::interprocess::read_write : boost::interprocess::read_only);
} else
}
else
{ // writeable pointer
// remove previously allocated mem
if (remove_prev)
@ -262,8 +259,7 @@ class SharedMemory : boost::noncopyable
region = boost::interprocess::mapped_region(shm, boost::interprocess::read_write);
remover.SetID(key);
SimpleLogger().Write(logDEBUG) <<
"writeable memory allocated " << size << " bytes";
SimpleLogger().Write(logDEBUG) << "writeable memory allocated " << size << " bytes";
}
}
@ -275,10 +271,8 @@ class SharedMemory : boost::noncopyable
char k[500];
build_key(id, k);
result = RegionExists(k);
} catch(...)
{
result = false;
}
catch (...) { result = false; }
return result;
}
@ -302,10 +296,8 @@ class SharedMemory : boost::noncopyable
{
boost::interprocess::shared_memory_object shm(
boost::interprocess::open_only, key, boost::interprocess::read_write);
} catch(...)
{
result = false;
}
catch (...) { result = false; }
return result;
}
@ -316,7 +308,8 @@ class SharedMemory : boost::noncopyable
{
SimpleLogger().Write(logDEBUG) << "deallocating prev memory";
ret = boost::interprocess::shared_memory_object::remove(key);
} catch(const boost::interprocess::interprocess_exception &e)
}
catch (const boost::interprocess::interprocess_exception &e)
{
if (e.get_error_code() != boost::interprocess::not_found_error)
{