Add docs for systems
This commit is contained in:
parent
4bbb286981
commit
b9255d6b77
3 changed files with 176 additions and 0 deletions
|
|
@ -12,28 +12,85 @@
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Main system class
|
||||||
|
*
|
||||||
|
*/
|
||||||
class apparatus {
|
class apparatus {
|
||||||
private:
|
private:
|
||||||
|
//! Static pointer instance
|
||||||
static apparatus *_instance;
|
static apparatus *_instance;
|
||||||
|
//! Static path to save file
|
||||||
static const QString filename;
|
static const QString filename;
|
||||||
|
|
||||||
|
//! Pointer to users subsystem
|
||||||
auth_system* _auth_system;
|
auth_system* _auth_system;
|
||||||
|
//! Pointer to objects subsystem
|
||||||
object_system* _object_system;
|
object_system* _object_system;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new apparatus object
|
||||||
|
*
|
||||||
|
*/
|
||||||
explicit apparatus();
|
explicit apparatus();
|
||||||
|
/**
|
||||||
|
* @brief Destroy the apparatus object
|
||||||
|
*
|
||||||
|
*/
|
||||||
~apparatus();
|
~apparatus();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the auth subsystem object
|
||||||
|
*
|
||||||
|
* @return auth_system*
|
||||||
|
*/
|
||||||
auth_system* get_auth_subsystem();
|
auth_system* get_auth_subsystem();
|
||||||
|
/**
|
||||||
|
* @brief Get the object subsystem object
|
||||||
|
*
|
||||||
|
* @return object_system*
|
||||||
|
*/
|
||||||
object_system* get_object_subsystem();
|
object_system* get_object_subsystem();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Saves system data to disk
|
||||||
|
*
|
||||||
|
*/
|
||||||
void save();
|
void save();
|
||||||
|
/**
|
||||||
|
* @brief Loads system data from disk
|
||||||
|
*
|
||||||
|
*/
|
||||||
void load();
|
void load();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Checks if it is first run
|
||||||
|
*
|
||||||
|
* @return true
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
static bool is_first_run();
|
static bool is_first_run();
|
||||||
|
/**
|
||||||
|
* @brief Generates lock file after initialization
|
||||||
|
*
|
||||||
|
*/
|
||||||
static void generate_lock_file();
|
static void generate_lock_file();
|
||||||
|
/**
|
||||||
|
* @brief Get ther main system object
|
||||||
|
*
|
||||||
|
* @return apparatus*
|
||||||
|
*/
|
||||||
static apparatus* instance();
|
static apparatus* instance();
|
||||||
|
/**
|
||||||
|
* @brief Initializes system on start
|
||||||
|
*
|
||||||
|
*/
|
||||||
static void init();
|
static void init();
|
||||||
|
/**
|
||||||
|
* @brief Shuts system down in the end
|
||||||
|
*
|
||||||
|
*/
|
||||||
static void shutdown();
|
static void shutdown();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,19 +6,66 @@
|
||||||
#include "../entities/user_entity.h"
|
#include "../entities/user_entity.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief User's manipulation subsystem
|
||||||
|
*
|
||||||
|
*/
|
||||||
class auth_system {
|
class auth_system {
|
||||||
private:
|
private:
|
||||||
|
//! Subsystem's users collection
|
||||||
QVector<user_entity> _users;
|
QVector<user_entity> _users;
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new auth system object
|
||||||
|
*
|
||||||
|
*/
|
||||||
auth_system() = default;
|
auth_system() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get user
|
||||||
|
*
|
||||||
|
* @param login user's login
|
||||||
|
* @param success operation success reference
|
||||||
|
* @return user_entity*
|
||||||
|
*/
|
||||||
user_entity* get_user(const QString &login, bool &success);
|
user_entity* get_user(const QString &login, bool &success);
|
||||||
|
/**
|
||||||
|
* @brief Remove user from subsystem
|
||||||
|
*
|
||||||
|
* @param login user's login
|
||||||
|
* @return true
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
bool remove_user(const QString &login);
|
bool remove_user(const QString &login);
|
||||||
|
/**
|
||||||
|
* @brief Registeer new user in system
|
||||||
|
*
|
||||||
|
* @param login new user's login
|
||||||
|
* @param password new usere's password
|
||||||
|
* @param role new user's role
|
||||||
|
* @return true
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
bool register_user(const QString &login, const QString &password, UserRole role);
|
bool register_user(const QString &login, const QString &password, UserRole role);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get subsystem immutable users collection
|
||||||
|
*
|
||||||
|
* @return const QVector<user_entity>&
|
||||||
|
*/
|
||||||
const QVector<user_entity>& users() const;
|
const QVector<user_entity>& users() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads subsytem's data from disk
|
||||||
|
*
|
||||||
|
* @param stream read stream
|
||||||
|
*/
|
||||||
void deserialize_data(QDataStream *stream);
|
void deserialize_data(QDataStream *stream);
|
||||||
|
/**
|
||||||
|
* @brief Writes subsytem's data to disk
|
||||||
|
*
|
||||||
|
* @param stream write stream
|
||||||
|
*/
|
||||||
void serialize_data(QDataStream *stream);
|
void serialize_data(QDataStream *stream);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,27 +7,99 @@
|
||||||
#include "../entities/vessel_entity.h"
|
#include "../entities/vessel_entity.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Object's manipulation subsystem
|
||||||
|
*
|
||||||
|
*/
|
||||||
class object_system {
|
class object_system {
|
||||||
private:
|
private:
|
||||||
|
//! Subsystem's DP collection
|
||||||
QVector<dpoint_entity> _dpoints;
|
QVector<dpoint_entity> _dpoints;
|
||||||
|
//! Subsystem's vessels collection
|
||||||
QVector<vessel_entity> _vessels;
|
QVector<vessel_entity> _vessels;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new object system object
|
||||||
|
*
|
||||||
|
*/
|
||||||
object_system() = default;
|
object_system() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get DP object
|
||||||
|
*
|
||||||
|
* @param oid DP's ID
|
||||||
|
* @param success operation success reference
|
||||||
|
* @return dpoint_entity*
|
||||||
|
*/
|
||||||
dpoint_entity* get_dpoint(entity_id oid, bool &success);
|
dpoint_entity* get_dpoint(entity_id oid, bool &success);
|
||||||
|
/**
|
||||||
|
* @brief Remove DP from subsystem
|
||||||
|
*
|
||||||
|
* @param oid DP's ID
|
||||||
|
* @return true
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
bool remove_dpoint(entity_id oid);
|
bool remove_dpoint(entity_id oid);
|
||||||
|
/**
|
||||||
|
* @brief Add DP to subsystem
|
||||||
|
*
|
||||||
|
* @param dpoint new DP object
|
||||||
|
* @return true
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
bool add_dpoint(dpoint_entity dpoint);
|
bool add_dpoint(dpoint_entity dpoint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get vessel object
|
||||||
|
*
|
||||||
|
* @param oid vessel ID
|
||||||
|
* @param success operation success reference
|
||||||
|
* @return vessel_entity*
|
||||||
|
*/
|
||||||
vessel_entity* get_vessel(entity_id oid, bool &success);
|
vessel_entity* get_vessel(entity_id oid, bool &success);
|
||||||
|
/**
|
||||||
|
* @brief Remove vessel from subsystem
|
||||||
|
*
|
||||||
|
* @param oid vessel's ID
|
||||||
|
* @return true
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
bool remove_vessel(entity_id oid);
|
bool remove_vessel(entity_id oid);
|
||||||
|
/**
|
||||||
|
* @brief Add vessel to subsystem
|
||||||
|
*
|
||||||
|
* @param dpoint
|
||||||
|
* @return true
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
bool add_vessel(vessel_entity dpoint);
|
bool add_vessel(vessel_entity dpoint);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get subsystem immutable DP collection
|
||||||
|
*
|
||||||
|
* @return const QVector<dpoint_entity>
|
||||||
|
*/
|
||||||
const QVector<dpoint_entity> dpoints() const;
|
const QVector<dpoint_entity> dpoints() const;
|
||||||
|
/**
|
||||||
|
* @brief Get subsystem immutable vessel collection
|
||||||
|
*
|
||||||
|
* @return const QVector<vessel_entity>
|
||||||
|
*/
|
||||||
const QVector<vessel_entity> vessels() const;
|
const QVector<vessel_entity> vessels() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads subsytem's data from disk
|
||||||
|
*
|
||||||
|
* @param stream read stream
|
||||||
|
*/
|
||||||
void deserialize_data(QDataStream *stream);
|
void deserialize_data(QDataStream *stream);
|
||||||
|
/**
|
||||||
|
* @brief Writes subsytem's data to disk
|
||||||
|
*
|
||||||
|
* @param stream write stream
|
||||||
|
*/
|
||||||
void serialize_data(QDataStream *stream);
|
void serialize_data(QDataStream *stream);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue