ROOT_Application
2.0
C++ Core modules and GUIStock
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src_gui_root
GUIStock.cxx
Go to the documentation of this file.
1
8
#include "../src_cpp/StockManager.h"
9
// include boost also
10
#include "../src_cpp/TCPServer.h"
11
#include "
GUIMainController.h
"
12
13
//#include "Garbage.h"
14
15
#include <TRint.h>
16
#include <TROOT.h>
17
#include <TGClient.h>
18
#include <TStyle.h>
19
20
//ok can be used to set global style for GUIStock
21
void
MyStyle
()
22
{
23
24
#ifdef DEBUG
25
std::cout <<
" Entry My Style "
<< std::endl;
26
#endif
27
28
TStyle *style_stock =
new
TStyle(
"style_stock"
,
"my style"
);
29
//std::cout << "style created" << std::endl;
30
31
// italic on X axis
32
// void SetLabelFont(Style_t font = 62, Option_t* axis = "X")
33
//style_stock->SetLabelFont( 72 );
34
style_stock->SetTitleBorderSize(0);
35
style_stock->cd();
// this becomes now the current style gStyle
36
//std::cout << " Out My Style " << std::endl;
37
}
38
39
/*
40
void example()
41
{
42
MyStyle();
43
//Stock *stock=new Stock("CAC40","CAC40",".");
44
//stock->LoadListData( DAY ,Indicator::StockCSV );
45
46
//previous method
47
//TVirtualHistPainter::SetPainter("THistPainterStock");
48
//THStock *ths=new THStock("toto","TOTO", (ListDataStock<DataCSV> *) stock->GetListData(DAY,Indicator::StockCSV));
49
50
//CanvasStock *can_s= new CanvasStock("CStock");
51
//can_s->PrintMap();
52
53
//can_s->AddListDataStockToMap(stock->GetListData(DAY,Indicator::StockCSV));
54
//can_s->AddListDataStockToMap(stock->GetListData(DAY,Indicator::Volume));
55
56
//THStockMainFrame *thsMF = new THStockMainFrame(gClient->GetRoot(),300,200);
57
58
//GUIMainFrame gui(gClient->GetRoot(),300,200);
59
//otherwise close direct, certainy bound to Run(KTrue) or to Cleanup()
60
GUIMainFrame *gui = new GUIMainFrame(gClient->GetRoot(),600,400);
61
}
62
*/
63
64
// could use argument -debug here (use data_test)
65
int
main
(
int
argc,
char
**argv)
66
{
67
//TApplication theApp("App",&argc,argv);
68
//TRint lets the interpreter usable ! good
69
// No, console as well if commented !
70
TROOT troot(
"troot"
,
"troot"
);
71
72
//if not a pointer, avoid an error with valgrind
73
TRint* theApp =
new
TRint(
"app"
,&argc,argv,0,0,kTRUE);
74
//std::cout << "theApp " << theApp << std::endl;
75
76
// here could load all Singleton and TALib initialisation
77
//or in a MainController
78
//TAlibAPI::Init();
79
//std::cout << TAlibAPI::GetStatus() << std::endl;
80
81
StockManager
*fstockmanager =
StockManager::getInstance
(
Utils::GetPathData
());
82
//std::cout << "GetStatus StockManager " << fstockmanager->GetStatus() << std::endl;
83
//std::cout << "GetStatus StockManager::Server " << fstockmanager->GetStatusServer() << std::endl;
84
85
/* original
86
boost::asio::io_service io_service;
87
TCPServer *serv = new TCPServer( fstockmanager, 9998, io_service );
88
*/
89
TCPServer
*serv =
new
TCPServer
( fstockmanager, 9998 );
90
// should not be necessary, only use to run and stop the server.
91
// Better if main_control->SetServer() //will control the server
92
/* original
93
fstockmanager->SetServer( serv );
94
// crash boost error, begin test without Server
95
fstockmanager->GetServer()->RunThreadServer();
96
*/
97
// New, thread created in constructor,
98
// Start should be called by GUIMainController
99
serv->
StartServer
();
100
101
#ifdef DEBUG
102
std::cout <<
"GetStatus StockManager "
<< fstockmanager->
GetStatus
() << std::endl;
103
std::cout <<
"GetStatus StockManager::GetStatusServer "
<< fstockmanager->GetStatusServer() << std::endl;
104
#endif
105
106
//example();
107
MyStyle
();
108
109
// now use GUIMainController intermediate
110
// with parent set to null
111
GUIMainController
*main_control =
new
GUIMainController
();
112
// Better if main_control->SetServer() //will control the server
113
114
// here stops after run
115
theApp->Run(kTRUE);
116
// executed when quitting the application
117
//std::cout << "stop app " << std::endl;
118
119
// valgrind complains, maybe not the reason, crash if done, but error maybe other
120
// test delete gui
121
std::cout <<
"GUIStock delete guimain_control"
<< std::endl;
122
123
delete
main_control;
124
main_control = 0;
125
126
delete
theApp;
127
theApp = 0;
128
129
// here crash...not when not killing StockManager, certainly because SM try to delete TCPServer
130
// now all pass
131
std::cout <<
" Stop and Delete TCPServer"
<< std::endl;
132
//serv->StopServer();
133
delete
serv;
134
serv =
nullptr
;
135
136
// delete StockManager ? Garbage ? they are static deleted at exit, to check for Garbage
137
// see unit_test tcpserver.cpp/constructor valgrind 2 block non-freed. To test more in suite_stockmanager
138
// certainly because of SMSubjet created on heap
139
StockManager::killInstance
();
140
fstockmanager =
nullptr
;
141
142
return
0;
143
}
StockManager
Singleton class, stores all loaded stocks.
Definition:
StockManager.h:42
GUIMainController
Main controller of the application, linked to the view GUIMainFrame.
Definition:
GUIMainController.h:36
StockManager::GetStatus
bool GetStatus() const
Indicates if the singleton has been initialized or is still valide.
Definition:
StockManager.h:101
GUIMainController.h
MyStyle
void MyStyle()
Definition:
GUIStock.cxx:21
StockManager::getInstance
static StockManager * getInstance(std::string new_path=".")
Get a singleton instance.
Definition:
StockManager.cpp:47
TCPServer::StartServer
void StartServer()
Start the server.
Definition:
TCPServer.cpp:111
main
int main(int argc, char **argv)
Definition:
GUIStock.cxx:65
TCPServer
Use with RealTime to receive messages from python ServerPortfolio.
Definition:
TCPServer.h:122
Utils::GetPathData
std::string GetPathData()
Definition:
Utils.cpp:42
StockManager::killInstance
static void killInstance()
Delete the instance and allocated ressources.
Definition:
StockManager.cpp:73
Generated on Mon May 25 2015 20:35:30 for ROOT_Application by
1.8.6