ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes
StockManager Class Reference

Singleton class, stores all loaded stocks. More...

#include <StockManager.h>

Collaboration diagram for StockManager:
Collaboration graph
[legend]

Public Member Functions

StockLoad (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 ()
 
TCPServerGetServer () const
 
void SetServer (TCPServer *tcp)
 
Retrieve elements in StockManager
StockFind (const std::string &namestock) const
 Retrieve an instance of a stock. More...
 
ListDataStockBaseGetListData (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
SMSubjectGetSubject ()
 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...
 
StockManageroperator= (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 StockManagerfstockmanager = 0
 static instance More...
 
static std::string fpath = "."
 path of the data, set during singleton initialization More...
 
static TCPServerftcp = 0
 owns a TCPServer, but inverse is true as well. More...
 
static SMSubjectfsubject = 0
 owns a subject/observable for the observer pattern More...
 

Getter/Setter

static StockManagergetInstance (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...
 

Detailed Description

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.

Member Typedef Documentation

typedef std::vector<Stock *>::const_iterator StockManager::cit_stock
private

Definition at line 48 of file StockManager.h.

typedef std::vector<Stock *>::iterator StockManager::it_stock
private

Definition at line 47 of file StockManager.h.

Constructor & Destructor Documentation

StockManager::StockManager ( )
inlineprivate

Constructor and destructor private, called by getInstance.

Definition at line 73 of file StockManager.h.

StockManager::~StockManager ( )
private

Definition at line 32 of file StockManager.cpp.

StockManager::StockManager ( const StockManager )
private

Desactivate copy and assignement.

Member Function Documentation

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.

Parameters
[in]pointerof the stock to insert
Returns
status

Definition at line 446 of file StockManager.cpp.

References Stock::GetName(), and Stock::MergeStock().

Referenced by MainControllerIndicatorTHStock::Validation().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
[in]frame_namestring CAC40_DAY

Definition at line 527 of file StockManager.cpp.

References FrameName::GetNameStock(), and FrameName::GetTimeScale().

Here is the call graph for this function:

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

Parameters
[in]namestockstring symbol stock
[in]Timescale

Definition at line 535 of file StockManager.cpp.

References Stock::DeleteAllListData(), Stock::GetName(), and Stock::IsEmpty().

Here is the call graph for this function:

void StockManager::DeleteListData ( const std::string &  fname)

Delete a specific ListDataStcok, just wrappers to Stock.

Parameters
[in]fnamefull 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().

Here is the call graph for this function:

Here is the caller graph for this function:

void StockManager::DeleteStock ( const std::string  namestock)

Delete a stock and all its content.

Parameters
[in]namestockname 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().

Here is the caller graph for this function:

StockManager * StockManager::getInstance ( std::string  new_path = ".")
static

Get a singleton instance.

Definition at line 47 of file StockManager.cpp.

Referenced by ControllerIndicatorTHStock::AddData(), GUIMainController::GUIMainController(), and main().

Here is the caller graph for this function:

StockManager::it_stock StockManager::GetItStock ( const std::string &  namestock)
private

Return iterator on the element.

Definition at line 107 of file StockManager.cpp.

StockManager::cit_stock StockManager::GetItStock ( const std::string &  namestock) const
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

Parameters
[in]fullnamefull name of the list,e.g., CAC40_DAY_StockCSV
Exceptions
StockException

Definition at line 337 of file StockManager.cpp.

References Stock::GetListData(), FullName::GetNameStock(), FullName::GetShortName(), and FullName::GetTimeScale().

Referenced by ControllerIndicatorTHStock::AddData().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string StockManager::GetPath ( ) const
inline

Definition at line 105 of file StockManager.h.

References fpath.

TCPServer* StockManager::GetServer ( ) const
inline

Definition at line 116 of file StockManager.h.

References ftcp.

bool StockManager::GetStatus ( ) const
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().

Here is the caller graph for this function:

SMSubject* StockManager::GetSubject ( )
inline

Get the subject instance.

Definition at line 196 of file StockManager.h.

References fsubject.

Referenced by GUIMainController::GUIMainController().

Here is the caller graph for this function:

void StockManager::InsertVec_Stock ( Stock stock)
private

Insert a vector.

Do not check if already in vec_stock ! must stay private

Definition at line 139 of file StockManager.cpp.

void StockManager::killInstance ( )
static

Delete the instance and allocated ressources.

Definition at line 73 of file StockManager.cpp.

Referenced by main().

Here is the caller graph for this function:

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

Parameters
[in]namestockstring or const char*
[in]tmsclTimescale
[in]indicIndicator::X object
[in]paramvector<int> containing the parameters
[in]datesoptional, a Utils::firstlast_date_struct
Returns
a pointer on the stock
Exceptions
StockException

Definition at line 367 of file StockManager.cpp.

References Stock::CheckLoaded(), Stock::LoadListData(), ShortName::MakeShortName(), and StockException::what().

Referenced by MainControllerIndicatorTHStock::Validation().

Here is the call graph for this function:

Here is the caller graph for this function:

StockManager& StockManager::operator= ( const StockManager )
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().

Here is the caller graph for this function:

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.

Parameters
messagemessage received by the TCPServer (without termination " END")
Exceptions
StockExceptionerror 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().

Here is the call graph for this function:

Here is the caller graph for this function:

void StockManager::SetPath ( std::string  new_path)
inline

set path during init, may be changed later also

Definition at line 107 of file StockManager.h.

References fpath.

void StockManager::SetServer ( TCPServer tcp)
inline

Definition at line 117 of file StockManager.h.

References ftcp.

Referenced by main().

Here is the caller graph for this function:

Field Documentation

std::string StockManager::fpath = "."
staticprivate

path of the data, set during singleton initialization

Definition at line 61 of file StockManager.h.

Referenced by GetPath(), and SetPath().

StockManager * StockManager::fstockmanager = 0
staticprivate

static instance

Definition at line 56 of file StockManager.h.

SMSubject * StockManager::fsubject = 0
staticprivate

owns a subject/observable for the observer pattern

Definition at line 66 of file StockManager.h.

Referenced by GetSubject().

TCPServer * StockManager::ftcp = 0
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().

bool StockManager::status_sm = false
staticprivate

static boolean status

Definition at line 54 of file StockManager.h.

Referenced by GetStatus().

std::vector< Stock * > StockManager::vec_stock
private

vector of loaded Stock

Definition at line 70 of file StockManager.h.


The documentation for this class was generated from the following files: