Commit 1d6567ec authored by Ilya Prokhorov's avatar Ilya Prokhorov

Big clean

parent 633942eb
......@@ -5,20 +5,20 @@
* Author: demensdeum
*/
#include "FSCObject.h"
#include "FSCController.h"
#include "Object.h"
#include "Controller.h"
using namespace std;
FSCController::FSCController() {
Controller::Controller() {
// TODO Auto-generated constructor stub
}
void FSCController::step() {
void Controller::step() {
}
FSCController::~FSCController() {
Controller::~Controller() {
// TODO Auto-generated destructor stub
}
......@@ -8,17 +8,23 @@
#ifndef FSCCONTROLLER_H_
#define FSCCONTROLLER_H_
#include "FSCObject.h"
#include "Object.h"
using namespace FlameSteelCore;
namespace FlameSteelCore {
/*! FSCController - controller class from MVC pattern */
class FSCController : public FSCObject {
class Controller : public Object {
public:
FSCController();
virtual ~FSCController();
Controller();
virtual ~Controller();
/*! step() - method to be called inside loop, represents one iteration of some process */
virtual void step();
};
};
#endif /* FSCCONTROLLER_H_ */
#include "FSCData.h"
#include "Data.h"
FSCData::FSCData() {
using namespace FlameSteelCore;
Data::Data() {
size = 0;
data = nullptr;
};
shared_ptr<FSCData> FSCData::fromFilePath(shared_ptr<string> filePath) {
shared_ptr<Data> Data::fromFilePath(shared_ptr<string> filePath) {
auto data = make_shared<FSCData>();
auto data = make_shared<Data>();
char *buffer = nullptr;
auto file = fopen (filePath->c_str(), "rb");
......
#ifndef FLAMESTEELCOREDATA
#define FLAMESTEELCOREDATA
#include <string>
#include <memory>
using namespace std;
class FSCData {
namespace FlameSteelCore {
class Data {
public:
FSCData();
static shared_ptr<FSCData> fromFilePath(shared_ptr<string> filePath);
Data();
static shared_ptr<Data> fromFilePath(shared_ptr<string> filePath);
size_t size;
char *data;
};
\ No newline at end of file
};
};
#endif
\ No newline at end of file
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: FSCSerializable.h
* Author: demensdeum
*
* Created on July 2, 2017, 10:13 AM
*/
#ifndef FSCSERIALIZABLE_H
#define FSCSERIALIZABLE_H
class FSCSerializable {
public:
FSCSerializable();
FSCSerializable(const FSCSerializable& orig);
virtual ~FSCSerializable();
private:
};
#endif /* FSCSERIALIZABLE_H */
/*
* FSCMessage.cpp
* Message.cpp
*
* Created on: Jul 30, 2016
* Author: demensdeum
*/
#include "FSCMessage.h"
#include "Message.h"
FSCMessage::FSCMessage(shared_ptr<string> title, shared_ptr<string> text) {
Message::Message(shared_ptr<string> title, shared_ptr<string> text) {
this->title = title;
this->text = text;
}
shared_ptr<string> FSCMessage::getTitle() {
shared_ptr<string> Message::getTitle() {
return this->title;
}
shared_ptr<string> FSCMessage::getText() {
shared_ptr<string> Message::getText() {
return this->text;
}
FSCMessage::~FSCMessage() {
Message::~Message() {
// TODO Auto-generated destructor stub
}
/*
* FSCMessage.h
* Message.h
*
* Created on: Jul 30, 2016
* Author: demensdeum
......@@ -8,31 +8,36 @@
#ifndef FSCMESSAGE_H_
#define FSCMESSAGE_H_
/*! FSCMessage - class used to send messages between objects */
/*! Message - class used to send messages between objects */
#include "FSCObject.h"
#include "Object.h"
#include <memory>
using namespace std;
using namespace FlameSteelCore;
class FSCMessage: public FSCObject {
namespace FlameSteelCore {
class Message: public Object {
public:
FSCMessage(shared_ptr<string> title, shared_ptr<string> text);
Message(shared_ptr<string> title, shared_ptr<string> text);
/*! FSCMessage - get message title @return title*/
/*! Message - get message title @return title*/
shared_ptr<string> getTitle();
/*! FSCMessage - get message text @return text*/
/*! Message - get message text @return text*/
shared_ptr<string> getText();
virtual ~FSCMessage();
virtual ~Message();
private:
shared_ptr<string> title;
shared_ptr<string> text;
};
};
#endif /* FSCMESSAGE_H_ */
/*
* FSCObject.cpp
* Object.cpp
*
* Created on: Jul 10, 2016
* Author: demensdeum
*/
#include "FSCObject.h"
#include "Object.h"
#include <iostream>
#include "FSCObjects.h"
#include "Objects.h"
#include <FlameSteelFramework/FlameSteelCore/sole.hpp>
using namespace std;
FSCObject::FSCObject() {
Object::Object() {
auto uuidContainer = sole::uuid0();
uuid = uuidContainer.str();
......@@ -21,49 +21,49 @@ FSCObject::FSCObject() {
classIdentifier = shared_ptr<string>();
instanceIdentifier = shared_ptr<string>();
components = make_shared<FSCObjects>();
components = make_shared<Objects>();
}
bool FSCObject::containsComponentWithIdentifier(shared_ptr<string> identifier) {
bool Object::containsComponentWithIdentifier(shared_ptr<string> identifier) {
return components->containsComponentWithIdentifier(identifier);
}
void FSCObject::setInstanceIdentifier(shared_ptr<string> instanceIdentifier) {
void Object::setInstanceIdentifier(shared_ptr<string> instanceIdentifier) {
this->instanceIdentifier = instanceIdentifier;
}
void FSCObject::setClassIdentifier(shared_ptr<string> classIdentifier) {
void Object::setClassIdentifier(shared_ptr<string> classIdentifier) {
this->classIdentifier = classIdentifier;
}
shared_ptr<string> FSCObject::getInstanceIdentifier() {
shared_ptr<string> Object::getInstanceIdentifier() {
return this->instanceIdentifier;
}
shared_ptr<string> FSCObject::getClassIdentifier() {
shared_ptr<string> Object::getClassIdentifier() {
return this->classIdentifier;
}
shared_ptr<FSCObject> FSCObject::getComponent(shared_ptr<string> identifier) {
shared_ptr<Object> Object::getComponent(shared_ptr<string> identifier) {
auto objects = components->objectsWithClassIdentifier(identifier);
if (objects.size() < 1)
{
string errorString = "FSCObject::getComponent - there is no component with class identifier: ";
string errorString = "Object::getComponent - there is no component with class identifier: ";
errorString += *identifier.get();
throw logic_error(errorString);
}
else if (objects.size() > 1)
{
string errorString = "FSCObject::getComponent - trying to get component from many components with same class identifier: ";
string errorString = "Object::getComponent - trying to get component from many components with same class identifier: ";
errorString += *identifier.get();
throw logic_error(errorString);
......@@ -75,12 +75,12 @@ shared_ptr<FSCObject> FSCObject::getComponent(shared_ptr<string> identifier) {
}
/*! removeComponent - remove component by identifier*/
void FSCObject::removeComponent(shared_ptr<string> identifier) {
void Object::removeComponent(shared_ptr<string> identifier) {
components->removeObjectWithClassIdentifier(identifier);
}
/*! addComponent - add component*/
void FSCObject::addComponent(shared_ptr<FSCObject> component) {
void Object::addComponent(shared_ptr<Object> component) {
if (component.get() == nullptr) {
......@@ -98,6 +98,6 @@ void FSCObject::addComponent(shared_ptr<FSCObject> component) {
components->addObject(component);
}
FSCObject::~FSCObject() {
Object::~Object() {
// TODO Auto-generated destructor stub
}
/*
* FSCObject.h
* Object.h
*
* Created on: Jul 10, 2016
* Author: demensdeum
......@@ -10,18 +10,20 @@
#include <string>
#include <memory>
#include "FSCSerializable.h"
#include "Serializable.h"
class FSCObjects;
class Objects;
using namespace std;
/*! FSCObject - base class of Flame Steel Core */
namespace FlameSteelCore {
class FSCObject : public FSCSerializable {
/*! Object - base class of Flame Steel Core */
class Object : public Serializable {
public:
FSCObject();
virtual ~FSCObject();
Object();
virtual ~Object();
string uuid;
......@@ -38,10 +40,10 @@ public:
shared_ptr<string> getClassIdentifier();
/*! addComponent - add component*/
void addComponent(shared_ptr<FSCObject> component);
void addComponent(shared_ptr<Object> component);
/*! getComponent - get component by identifier*/
shared_ptr<FSCObject> getComponent(shared_ptr<string> identifier);
shared_ptr<Object> getComponent(shared_ptr<string> identifier);
/*! removeComponent - remove component by identifier*/
void removeComponent(shared_ptr<string> identifier);
......@@ -56,7 +58,9 @@ private:
shared_ptr<string> classIdentifier;
/*! components - getter list of components from CES pattern @return components*/
shared_ptr<FSCObjects> components;
shared_ptr<Objects> components;
};
};
......
/*
* FSCObjects.cpp
* Objects.cpp
*
* Created on: Jul 31, 2016
* Author: demensdeum
*/
#include "FSCObjects.h"
#include "Objects.h"
#include <cstddef>
#include <iostream>
FSCObjects::FSCObjects() {
Objects::Objects() {
}
bool FSCObjects::containsComponentWithIdentifier(shared_ptr<string> identifier) {
bool Objects::containsComponentWithIdentifier(shared_ptr<string> identifier) {
return classIdentifierToComponentMap.find(*identifier) != classIdentifierToComponentMap.end();
}
void FSCObjects::addObject(shared_ptr<FSCObject> object) {
void Objects::addObject(shared_ptr<Object> object) {
if (object->getClassIdentifier().get() == nullptr) {
......@@ -62,14 +62,14 @@ void FSCObjects::addObject(shared_ptr<FSCObject> object) {
}
else
{
vector<shared_ptr<FSCObject> > objects;
vector<shared_ptr<Object> > objects;
objects.push_back(object);
classIdentifierToComponentMap[classIdentifierString] = objects;
}
}
void FSCObjects::removeObject(shared_ptr<FSCObject> object) {
void Objects::removeObject(shared_ptr<Object> object) {
if (object.get() == nullptr)
{
......@@ -91,31 +91,31 @@ void FSCObjects::removeObject(shared_ptr<FSCObject> object) {
}
shared_ptr<FSCObject> FSCObjects::objectWithUUID(string uuid) {
shared_ptr<Object> Objects::objectWithUUID(string uuid) {
return uuidToObject[uuid];
}
shared_ptr<FSCObject> FSCObjects::objectAtIndex(unsigned int index) {
shared_ptr<Object> Objects::objectAtIndex(unsigned int index) {
if (index >= objects.size()) {
return shared_ptr<FSCObject>();
return shared_ptr<Object>();
}
return objects[index];
}
int FSCObjects::size() {
int Objects::size() {
return objects.size();
}
void FSCObjects::removeObjectAtIndex(unsigned int index) {
void Objects::removeObjectAtIndex(unsigned int index) {
if (index < objects.size()) {
objects.erase(objects.begin() + index);
}
}
void FSCObjects::removeAllObjects() {
void Objects::removeAllObjects() {
objects.clear();
uuidToObject.clear();
......@@ -124,13 +124,13 @@ void FSCObjects::removeAllObjects() {
}
void FSCObjects::removeObjectWithClassIdentifier(shared_ptr<string> classIdentifier) {
void Objects::removeObjectWithClassIdentifier(shared_ptr<string> classIdentifier) {
throw logic_error("FSCObjects::removeObjectWithClassIdentifier unimplemented");
throw logic_error("Objects::removeObjectWithClassIdentifier unimplemented");
}
vector<shared_ptr<FSCObject> > FSCObjects::objectsWithClassIdentifier(shared_ptr<string> identifier) {
vector<shared_ptr<Object> > Objects::objectsWithClassIdentifier(shared_ptr<string> identifier) {
auto classIdentifierString = *identifier.get();
......@@ -143,14 +143,14 @@ vector<shared_ptr<FSCObject> > FSCObjects::objectsWithClassIdentifier(shared_ptr
}
else {
vector<shared_ptr<FSCObject> > emptyVector;
vector<shared_ptr<Object> > emptyVector;
return emptyVector;
}
}
shared_ptr<FSCObject> FSCObjects::objectWithInstanceIdentifier(shared_ptr<string> instanceIdentifier) {
shared_ptr<Object> Objects::objectWithInstanceIdentifier(shared_ptr<string> instanceIdentifier) {
auto instanceIdentifierString = *instanceIdentifier.get();
......@@ -163,11 +163,11 @@ shared_ptr<FSCObject> FSCObjects::objectWithInstanceIdentifier(shared_ptr<string
}
else {
return shared_ptr<FSCObject>();
return shared_ptr<Object>();
}
}
FSCObjects::~FSCObjects() {
Objects::~Objects() {
// TODO Auto-generated destructor stub
}
/*
* FSCObjects.h
* Objects.h
*
* Created on: Jul 31, 2016
* Author: demensdeum
......@@ -8,7 +8,7 @@
#ifndef FSCOBJECTS_H_
#define FSCOBJECTS_H_
#include "FSCObject.h"
#include "Object.h"
#include <vector>
#include <memory>
......@@ -16,35 +16,36 @@
#include <map>
using namespace std;
using namespace FlameSteelCore;
class FSCObjects {
class Objects {
public:
FSCObjects();
Objects();
void addObject(shared_ptr<FSCObject> object);
void addObject(shared_ptr<Object> object);
void removeObjectAtIndex(unsigned int index);
void removeAllObjects();
shared_ptr<FSCObject> objectWithUUID(string uuid);
shared_ptr<FSCObject> objectAtIndex(unsigned int index);
vector<shared_ptr<FSCObject> > objectsWithClassIdentifier(shared_ptr<string> identifier);
shared_ptr<FSCObject> objectWithInstanceIdentifier(shared_ptr<string> instanceIdentifier);
shared_ptr<Object> objectWithUUID(string uuid);
shared_ptr<Object> objectAtIndex(unsigned int index);
vector<shared_ptr<Object> > objectsWithClassIdentifier(shared_ptr<string> identifier);
shared_ptr<Object> objectWithInstanceIdentifier(shared_ptr<string> instanceIdentifier);
void removeObject(shared_ptr<FSCObject> object);
void removeObject(shared_ptr<Object> object);
void removeObjectWithClassIdentifier(shared_ptr<string> classIdentifier);
bool containsComponentWithIdentifier(shared_ptr<string> identifier);
int size();
virtual ~FSCObjects();
virtual ~Objects();
private:
vector <shared_ptr<FSCObject> > objects;
vector <shared_ptr<Object> > objects;
map <string, shared_ptr<FSCObject> > uuidToObject;
map<string, vector<shared_ptr<FSCObject>> > classIdentifierToComponentMap;
map<string, shared_ptr<FSCObject> > instanceIdentifierToObjectMap;
map <string, shared_ptr<Object> > uuidToObject;
map<string, vector<shared_ptr<Object>> > classIdentifierToComponentMap;
map<string, shared_ptr<Object> > instanceIdentifierToObjectMap;
};
......
/*
* FSCResource.cpp
* Resource.cpp
*
* Created on: Jan 16, 2017
* Author: demensdeum
*/
#include "FSCResource.h"
#include "Resource.h"
FSCResource::FSCResource() {
Resource::Resource() {
}
FSCResource::~FSCResource() {
Resource::~Resource() {
}
......@@ -8,12 +8,17 @@
#ifndef FSCRESOURCE_H_
#define FSCRESOURCE_H_
#include "FSCObject.h"
#include "Object.h"
class FSCResource: public FSCObject {
using namespace FlameSteelCore;
namespace FlameSteelCore {
class Resource: public Object {
public:
FSCResource();
virtual ~FSCResource();
Resource();
virtual ~Resource();
};
};
#endif /* FSCRESOURCE_H_ */
......@@ -5,29 +5,29 @@
*/
/*
* File: FSCResourceLoader.cpp
* File: ResourceLoader.cpp
* Author: demensdeum
*
* Created on March 12, 2017, 9:28 AM
*/
#include "FSCResourcesLoader.h"
#include "ResourcesLoader.h"
#include <iostream>
using namespace std;
FSCResourcesLoader::FSCResourcesLoader() {
ResourcesLoader::ResourcesLoader() {
}
FSCResourcesLoader::FSCResourcesLoader(const FSCResourcesLoader& ) {
ResourcesLoader::ResourcesLoader(const ResourcesLoader& ) {
}
void FSCResourcesLoader::loadURL(shared_ptr<string> , shared_ptr<FSCResourcesManager> ){
void ResourcesLoader::loadURL(shared_ptr<string> , shared_ptr<ResourcesManager> ){
cout << "FSCResourcesLoader: loadURL must be overridden." << endl;
cout << "ResourcesLoader: loadURL must be overridden." << endl;
exit(1);
}
FSCResourcesLoader::~FSCResourcesLoader() {
ResourcesLoader::~ResourcesLoader() {
}
\ No newline at end of file
......@@ -5,7 +5,7 @@
*/
/*
* File: FSCResourceLoader.h
* File: ResourceLoader.h
* Author: demensdeum
*
* Created on March 12, 2017, 9:28 AM
......@@ -14,19 +14,22 @@
#ifndef FSCRESOURCELOADER_H
#define FSCRESOURCELOADER_H
#include "FSCResource.h"
#include "FSCResourcesManager.h"
#include "Resource.h"
#include "ResourcesManager.h"
class FSCResourcesLoader {
namespace FlameSteelCore {
class ResourcesLoader {
public:
FSCResourcesLoader();
FSCResourcesLoader(const FSCResourcesLoader& orig);
virtual ~FSCResourcesLoader();
ResourcesLoader();
ResourcesLoader(const ResourcesLoader& orig);
virtual ~ResourcesLoader();
virtual void loadURL(shared_ptr<string> url, shared_ptr<FSCResourcesManager> resourcesManager);
virtual void loadURL(shared_ptr<string> url, shared_ptr<ResourcesManager> resourcesManager);
private:
};
};
#endif /* FSCRESOURCELOADER_H */
......