Commit ff2d0bf8 authored by Ilya Prokhorov's avatar Ilya Prokhorov

uuid based id for objects

parent 5f010936
......@@ -10,20 +10,20 @@
#include <iostream>
using namespace std;
#include <boost/uuid/uuid_io.hpp>
#include <boost/uuid/random_generator.hpp>
int FSCLastObjectID = 0;
using namespace std;
FSCObject::FSCObject() {
id = FSCLastObjectID;
classIdentifier = shared_ptr<string>();
instanceIdentifier = shared_ptr<string>();
components = shared_ptr<FSCComponents>();
boost::uuids::random_generator generator;
uuid = boost::uuids::to_string(generator());
classIdentifier = shared_ptr<string>();
instanceIdentifier = shared_ptr<string>();
FSCLastObjectID++;
components = shared_ptr<FSCComponents>();
}
void FSCObject::setInstanceIdentifier(shared_ptr<string> instanceIdentifier) {
......
......@@ -16,16 +16,14 @@ class FSCComponents;
using namespace std;
/*! FSCObject - base class of Flame Steel Engine */
extern int FSCLastObjectID;
/*! FSCObject - base class of Flame Steel Core */
class FSCObject : public FSCSerializable {
public:
FSCObject();
virtual ~FSCObject();
int id;
string uuid;
/*! instanceIdentifier setter - string identifier of object */
void setInstanceIdentifier(shared_ptr<string> gameSceneIdentifier);
......
......@@ -15,14 +15,13 @@ FSCObjects::FSCObjects() {
void FSCObjects::addObject(shared_ptr<FSCObject> object) {
objects.push_back(object);
idToObject[object->id] = object;
objects.push_back(object);
uuidToObject[object->uuid] = object;
}
shared_ptr<FSCObject> FSCObjects::objectWithId(int id) {
shared_ptr<FSCObject> FSCObjects::objectWithUUID(string uuid) {
return idToObject[id];
return uuidToObject[uuid];
}
......
......@@ -23,7 +23,7 @@ public:
void addObject(shared_ptr<FSCObject> object);
shared_ptr<FSCObject> objectWithId(int id);
shared_ptr<FSCObject> objectWithUUID(string uuid);
shared_ptr<FSCObject> objectAtIndex(unsigned int index);
......@@ -38,7 +38,7 @@ public:
private:
vector <shared_ptr<FSCObject> > objects;
map <int, shared_ptr<FSCObject> > idToObject;
map <string, shared_ptr<FSCObject> > uuidToObject;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment