ROOT_Application
2.0
C++ Core modules and GUIStock
|
Singleton class, stores all loaded stocks. More...
#include <StockManager.h>
Public Member Functions | |
Stock * | Load (const std::string namestock, const ETime &tmscl, const Indicator &indic, std::vector< int > param=std::vector< int >(), Utils::firstlast_dates dates=Utils::get_fldate_default()) throw (StockException) |
Load a specific ListDataStock. More... | |
int | AddStock (Stock *) |
Add a stock to the stockmanager. More... | |
void | PrintMap () |
Print an user-friendly view of the StockManger content. More... | |
Releted to the server | |
bool | ActivateServer () |
Activate the server, by default null in constructor. More... | |
bool | DesactivateServer () |
TCPServer * | GetServer () const |
void | SetServer (TCPServer *tcp) |
Retrieve elements in StockManager | |
Stock * | Find (const std::string &namestock) const |
Retrieve an instance of a stock. More... | |
ListDataStockBase * | GetListData (const std::string &fullname) const throw (StockException) |
Retrieve an instance of a ListDataStock. More... | |
Deletion of elements | |
void | DeleteStock (const std::string namestock) |
Delete a stock and all its content. More... | |
void | DeleteListData (const std::string &fname) |
Delete a specific ListDataStcok, just wrappers to Stock. More... | |
void | DeleteAllListDataFromFrame (const std::string &frame_name) |
Delete all data of a frame_name,i.e, CAC40_DAY just easy to use from GUI, just call DeleteAllListDataFromTimeScale. More... | |
void | DeleteAllListDataFromTimeScale (const std::string &namestock, const ETime &tmscl) |
Delete all listdata of a stock for a timescale. More... | |
Related to the observer pattern and the object SMSuject | |
SMSubject * | GetSubject () |
Get the subject instance. More... | |
void | SendDatadCSV (const std::string &message) throw (StockException) |
Extract info from the message coming from TCPServer, update the Lists and notify observers (GUIMainController) with a new message. More... | |
Private Types | |
typedef only for internal use | |
typedef std::vector< Stock * > ::iterator | it_stock |
typedef std::vector< Stock * > ::const_iterator | cit_stock |
Private Member Functions | |
StockManager () | |
Constructor and destructor private, called by getInstance. More... | |
~StockManager () | |
StockManager (const StockManager &) | |
Desactivate copy and assignement. More... | |
StockManager & | operator= (const StockManager &) |
Get and insert elements in vector, internal use | |
void | InsertVec_Stock (Stock *) |
Insert a vector. More... | |
it_stock | GetItStock (const std::string &namestock) |
Return iterator on the element. More... | |
cit_stock | GetItStock (const std::string &namestock) const |
Return constant iterator on the element. More... | |
Private Attributes | |
std::vector< Stock * > | vec_stock |
vector of loaded Stock More... | |
Static Private Attributes | |
stuffs for singleton, all static | |
static bool | status_sm = false |
static boolean status More... | |
static StockManager * | fstockmanager = 0 |
static instance More... | |
static std::string | fpath = "." |
path of the data, set during singleton initialization More... | |
static TCPServer * | ftcp = 0 |
owns a TCPServer, but inverse is true as well. More... | |
static SMSubject * | fsubject = 0 |
owns a subject/observable for the observer pattern More... | |
Getter/Setter | |
static StockManager * | getInstance (std::string new_path=".") |
Get a singleton instance. More... | |
static void | killInstance () |
Delete the instance and allocated ressources. More... | |
bool | GetStatus () const |
Indicates if the singleton has been initialized or is still valide. More... | |
std::string | GetPath () const |
void | SetPath (std::string new_path) |
set path during init, may be changed later also More... | |
Singleton class, stores all loaded stocks.
Has a TCPServer as member.
Has SMSubject, a subject of the observer pattern to send update info to GUI.
Definition at line 42 of file StockManager.h.
|
private |
Definition at line 48 of file StockManager.h.
|
private |
Definition at line 47 of file StockManager.h.
|
inlineprivate |
Constructor and destructor private, called by getInstance.
Definition at line 73 of file StockManager.h.
|
private |
Definition at line 32 of file StockManager.cpp.
|
private |
Desactivate copy and assignement.
bool StockManager::ActivateServer | ( | ) |
Activate the server, by default null in constructor.
Definition at line 146 of file StockManager.cpp.
int StockManager::AddStock | ( | Stock * | stock | ) |
Add a stock to the stockmanager.
To use if the stock has been created outside of the stockmanager.
[in] | pointer | of the stock to insert |
Definition at line 446 of file StockManager.cpp.
References Stock::GetName(), and Stock::MergeStock().
Referenced by MainControllerIndicatorTHStock::Validation().
void StockManager::DeleteAllListDataFromFrame | ( | const std::string & | frame_name | ) |
Delete all data of a frame_name,i.e, CAC40_DAY just easy to use from GUI, just call DeleteAllListDataFromTimeScale.
[in] | frame_name | string CAC40_DAY |
Definition at line 527 of file StockManager.cpp.
References FrameName::GetNameStock(), and FrameName::GetTimeScale().
void StockManager::DeleteAllListDataFromTimeScale | ( | const std::string & | namestock, |
const ETime & | tmscl | ||
) |
Delete all listdata of a stock for a timescale.
check if stock is empty and will be deleted from stockmanager
[in] | namestock | string symbol stock |
[in] | Timescale |
Definition at line 535 of file StockManager.cpp.
References Stock::DeleteAllListData(), Stock::GetName(), and Stock::IsEmpty().
void StockManager::DeleteListData | ( | const std::string & | fname | ) |
Delete a specific ListDataStcok, just wrappers to Stock.
[in] | fname | full name of the list |
Definition at line 476 of file StockManager.cpp.
References Stock::DeleteListData(), Stock::GetName(), FullName::GetNameStock(), FullName::GetShortName(), FullName::GetTimeScale(), and Stock::IsEmpty().
Referenced by ControllerIndicatorTHStock::UpdateIndicator().
void StockManager::DeleteStock | ( | const std::string | namestock | ) |
Delete a stock and all its content.
[in] | namestock | name of the stock |
Definition at line 576 of file StockManager.cpp.
bool StockManager::DesactivateServer | ( | ) |
Definition at line 162 of file StockManager.cpp.
Stock * StockManager::Find | ( | const std::string & | namestock | ) | const |
Retrieve an instance of a stock.
Definition at line 323 of file StockManager.cpp.
Referenced by MainControllerIndicatorTHStock::Validation().
|
static |
Get a singleton instance.
Definition at line 47 of file StockManager.cpp.
Referenced by ControllerIndicatorTHStock::AddData(), GUIMainController::GUIMainController(), and main().
|
private |
Return iterator on the element.
Definition at line 107 of file StockManager.cpp.
|
private |
Return constant iterator on the element.
Definition at line 122 of file StockManager.cpp.
ListDataStockBase * StockManager::GetListData | ( | const std::string & | fullname | ) | const |
throw | ( | StockException | |||
) |
Retrieve an instance of a ListDataStock.
Return a pointer on the list, ownership stays in StockManager
[in] | fullname | full name of the list,e.g., CAC40_DAY_StockCSV |
StockException |
Definition at line 337 of file StockManager.cpp.
References Stock::GetListData(), FullName::GetNameStock(), FullName::GetShortName(), and FullName::GetTimeScale().
Referenced by ControllerIndicatorTHStock::AddData().
|
inline |
Definition at line 105 of file StockManager.h.
References fpath.
|
inline |
Definition at line 116 of file StockManager.h.
References ftcp.
|
inline |
Indicates if the singleton has been initialized or is still valide.
Definition at line 101 of file StockManager.h.
References status_sm.
Referenced by main().
|
inline |
Get the subject instance.
Definition at line 196 of file StockManager.h.
References fsubject.
Referenced by GUIMainController::GUIMainController().
|
private |
Insert a vector.
Do not check if already in vec_stock ! must stay private
Definition at line 139 of file StockManager.cpp.
|
static |
Delete the instance and allocated ressources.
Definition at line 73 of file StockManager.cpp.
Referenced by main().
Stock * StockManager::Load | ( | const std::string | namestock, |
const ETime & | tmscl, | ||
const Indicator & | indic, | ||
std::vector< int > | param = std::vector<int>() , |
||
Utils::firstlast_dates | dates = Utils::get_fldate_default() |
||
) | |||
throw | ( | StockException | |
) |
Load a specific ListDataStock.
Mainly called from GUI, try to Find or create and insert a new Stock. Then call Stock::LoadListData which throw StockException errors
[in] | namestock | string or const char* |
[in] | tmscl | Timescale |
[in] | indic | Indicator::X object |
[in] | param | vector<int> containing the parameters |
[in] | dates | optional, a Utils::firstlast_date_struct |
StockException |
Definition at line 367 of file StockManager.cpp.
References Stock::CheckLoaded(), Stock::LoadListData(), ShortName::MakeShortName(), and StockException::what().
Referenced by MainControllerIndicatorTHStock::Validation().
|
private |
void StockManager::PrintMap | ( | ) |
Print an user-friendly view of the StockManger content.
To use for development.
Definition at line 606 of file StockManager.cpp.
Referenced by MainControllerIndicatorTHStock::Validation().
void StockManager::SendDatadCSV | ( | const std::string & | message | ) | |
throw | ( | StockException | |||
) |
Extract info from the message coming from TCPServer, update the Lists and notify observers (GUIMainController) with a new message.
The exception is throw to an independent thread, not so easy to catch the exception.
But the function will not crash in case of a bad format of the message.
message | message received by the TCPServer (without termination " END") |
StockException | error in parsing the string mainly |
Definition at line 207 of file StockManager.cpp.
References ListDataStockBase::AddData(), Stock::AddListDataToMap(), Utils::ERROR_StrToTime, Stock::GetListData(), INST, SimpleData::PrintData(), SimpleData::SetData(), ListDataStockBase::SetDates(), Utils::splitline(), Indicator::StockInst, Utils::StringToTime_t(), and Stock::Updated().
Referenced by TCPServer::handle_accept().
|
inline |
set path during init, may be changed later also
Definition at line 107 of file StockManager.h.
References fpath.
|
inline |
Definition at line 117 of file StockManager.h.
References ftcp.
Referenced by main().
|
staticprivate |
path of the data, set during singleton initialization
Definition at line 61 of file StockManager.h.
|
staticprivate |
static instance
Definition at line 56 of file StockManager.h.
|
staticprivate |
owns a subject/observable for the observer pattern
Definition at line 66 of file StockManager.h.
Referenced by GetSubject().
|
staticprivate |
owns a TCPServer, but inverse is true as well.
Better if unidirectional
Definition at line 64 of file StockManager.h.
Referenced by GetServer(), and SetServer().
|
staticprivate |
|
private |
vector of loaded Stock
Definition at line 70 of file StockManager.h.