|
#pragma once
#include <string>
using std::string;
#include <map>
using std::map;
class MMF;
class SharedMemory
{
/************************************************************************/
/*
the class SharedMemory uses the Singleton pattern
* @author Bony.Chen
* @description
the SharedMemory object can contain multiple memory-mapped
file objects and one MMF object has special name.the object
is implemented using Singleton pattern.
* @mail bonyren@163.com
*/
/************************************************************************/
protected:
SharedMemory();
private:
SharedMemory(const SharedMemory& sm)
{
}
SharedMemory& operator= (const SharedMemory& sm)
{
}
public:
virtual ~SharedMemory(void);
public:
///Get the only instance object
static SharedMemory& Instance();
///write data to the special MMF that named 'szName'
bool WriteSharedMemory(const string& szName,const string& szValue);
///read data from the special MMF that named 'szName'
bool ReadSharedMemory(const string& szName,string& szValue);
///delete the special MMF that named 'szName'
void DeleteSharedMemory(const string& szName);
private:
map<string,MMF*> m_mapMMF;//<the container of MMFs
};
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Bony Chen, a senior software engineer, specializes in C++, COM, C#, ASP.net, ISAPI. He has nearly seven years of software development experience, and has successfully developed many influential software products, such as SPES, CSO, QQ (a famous IM tool in China).
And now he is focusing on P2P technology. He aims at being an expert in software development, software consulting, software components and computer science.
If you have any opinions or questions in software area, please contact bonyren@163.com.