-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObjectBase.cpp
49 lines (39 loc) · 945 Bytes
/
ObjectBase.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "BaseLib/ObjectBase.h"
#include "BaseLib/ObjectManager.h"
#include "BaseLib/MutexLocker.h"
#include <sstream>
using namespace std;
namespace BaseLib
{
ObjectBase::ObjectBase(std::string objectName) : name_(objectName)
{
if(name_.empty() == true)
{
static int count = 0;
stringstream ostr;
ostr << "BaseLib.ObjectBase." << count++;
name_ = ostr.str();
}
ObjectManager::getObjectManager()->AddObject(this);
}
ObjectBase::~ObjectBase()
{
ObjectManager::getObjectManager()->RemoveObject(this);
}
std::string ObjectBase::Name() const throw()
{
MutexLocker lock(&mutex_);
return name_;
}
void ObjectBase::SetName(std::string name) throw()
{
MutexLocker lock(&mutex_);
name_ = name;
}
//shared_ptr<ObjectBase> ObjectBase::create()
//{
// shared_ptr<ObjectBase> px(new ObjectBase());
// create weak pointers from px here
// return px;
//}
} // namespace BaseLib