Commit 505c91a3 authored by Ilya Prokhorov's avatar Ilya Prokhorov

Code-style refactoring

parent 40825f06
......@@ -11,14 +11,10 @@
using namespace std;
Controller::Controller() {
// TODO Auto-generated constructor stub
}
void Controller::step() {
}
Controller::~Controller() {
// TODO Auto-generated destructor stub
}
......@@ -14,14 +14,10 @@ using namespace FlameSteelCore;
namespace FlameSteelCore {
/*! FSCController - controller class from MVC pattern */
class Controller : public Object {
public:
Controller();
virtual ~Controller();
/*! step() - method to be called inside loop, represents one iteration of some process */
virtual void step();
};
......
......@@ -13,17 +13,15 @@
using namespace std;
FSCUtils::FSCUtils() {
// TODO Auto-generated constructor stub
namespace FlameSteelCore {
namespace Utils {
}
void FSCUtils::throwRuntimeException(string error) {
void throwRuntimeException(string error) {
cout << error << endl;
throw runtime_error(error);
};
int FSCUtils::FSCRandomInt(int maximalInt) {
int RandomInt(int maximalInt) {
if (maximalInt == 0) {
return 0;
......@@ -34,21 +32,14 @@ int FSCUtils::FSCRandomInt(int maximalInt) {
return randomInt;
}
bool FSCUtils::FSCRandomBool() {
return FSCRandomInt(2);
bool RandomBool() {
return RandomInt(2);
}
shared_ptr<string> FSCUtils::localizedString(shared_ptr<string> key) {
shared_ptr<string> localizedString(shared_ptr<string> key) {
return key;
}
FSCUtils::~FSCUtils() {
// TODO Auto-generated destructor stub
}
string FlameSteelCore::Utils::LocalizedString(const char *key) {
return string(key);
}
}
\ No newline at end of file
......@@ -13,30 +13,15 @@
using namespace std;
/*! FSCUtils - contains common utils functions for Flame Steel Engine */
class FSCUtils {
public:
FSCUtils();
/*! FSCRandomUInt - return random unsigned integer from zero to maximalUInt*/
static int FSCRandomInt(int maximalInt);
static bool FSCRandomBool();
static shared_ptr<string> localizedString(shared_ptr<string> key);
static void throwRuntimeException(string error);
virtual ~FSCUtils();
};
namespace FlameSteelCore {
namespace Utils {
string LocalizedString(const char *key);
int RandomInt(int maximalInt);
bool RandomBool();
shared_ptr<string> localizedString(shared_ptr<string> key);
void throwRuntimeException(string error);
}
}
};
};
#endif /* FSCUTILS_H_ */
......@@ -22,15 +22,8 @@ namespace FlameSteelCore {
class Message: public Object {
public:
Message(shared_ptr<string> title, shared_ptr<string> text);
/*! Message - get message title @return title*/
shared_ptr<string> getTitle();
/*! Message - get message text @return text*/
shared_ptr<string> getText();
virtual ~Message();
private:
......
......@@ -12,6 +12,7 @@
#include <FlameSteelCore/FSCUtils.h>
using namespace std;
using namespace FlameSteelCore::Utils;
Object::Object() {
......@@ -59,14 +60,14 @@ shared_ptr<Object> Object::getComponent(shared_ptr<string> identifier) {
string errorString = "Object::getComponent - there is no component with class identifier: ";
errorString += *identifier.get();
FSCUtils::throwRuntimeException(errorString);
throwRuntimeException(errorString);
}
else if (objects.size() > 1)
{
string errorString = "Object::getComponent - trying to get component from many components with same class identifier: ";
errorString += *identifier.get();
FSCUtils::throwRuntimeException(errorString);
throwRuntimeException(errorString);
}
auto object = objects[0];
......@@ -99,5 +100,4 @@ void Object::addComponent(shared_ptr<Object> component) {
}
Object::~Object() {
// TODO Auto-generated destructor stub
}
......@@ -23,34 +23,19 @@ static unsigned long long int FSGL_OBJECT_ID = 0;
namespace FlameSteelCore {
/*! Object - base class of Flame Steel Core */
class Object : public Serializable {
public:
Object();
virtual ~Object();
string uuid;
/*! instanceIdentifier setter - string identifier of object */
void setInstanceIdentifier(shared_ptr<string> gameSceneIdentifier);
/*! classIdentifier setter - string identifier of object class */
void setClassIdentifier(shared_ptr<string> gameSceneClass);
/*! instanceIdentifier - getter string identifier of object @return instanceIdentifier*/
shared_ptr<string> getInstanceIdentifier();
/*! instanceIdentifier - getter string identifier of object @return classIdentifier*/
shared_ptr<string> getClassIdentifier();
/*! addComponent - add component*/
void addComponent(shared_ptr<Object> component);
/*! getComponent - get component by identifier*/
shared_ptr<Object> getComponent(shared_ptr<string> identifier);
/*! removeComponent - remove component by identifier*/
void removeComponent(shared_ptr<string> identifier);
bool containsComponentWithIdentifier(shared_ptr<string> identifier);
......@@ -58,13 +43,9 @@ public:
string debugIdentifier = "";
private:
/*! instanceIdentifier - string identifier of object */
shared_ptr<string> instanceIdentifier;
/*! classIdentifier - string identifier of object class */
shared_ptr<string> classIdentifier;
/*! components - getter list of components from CES pattern @return components*/
shared_ptr<Objects> components;
};
......
......@@ -11,6 +11,8 @@
#include <iostream>
#include <FlameSteelCore/FSCUtils.h>
using namespace FlameSteelCore::Utils;
Objects::Objects() {
}
......@@ -37,7 +39,7 @@ void Objects::addObject(shared_ptr<Object> object) {
if (object->getClassIdentifier().get() == nullptr) {
FSCUtils::throwRuntimeException(string("Trying to add object with classIdentifier = nullptr"));
throwRuntimeException(string("Trying to add object with classIdentifier = nullptr"));
}
......@@ -46,7 +48,7 @@ void Objects::addObject(shared_ptr<Object> object) {
string errorString = "Trying to add object with instanceIdentifier = nullptr; With class identifier: ";
errorString += *object->getClassIdentifier().get();
FSCUtils::throwRuntimeException(errorString);
throwRuntimeException(errorString);
}
......@@ -86,7 +88,7 @@ void Objects::removeObject(shared_ptr<Object> object) {
if (object.get() == nullptr)
{
FSCUtils::throwRuntimeException(string("Trying to remove nullptr object"));
throwRuntimeException(string("Trying to remove nullptr object"));
}
auto index = 0;
......
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