ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MainControllerIndicatorTHStock.cxx
Go to the documentation of this file.
1 
11 
13 #include "../View/MainIndicatorTHStockFrame.h"
14 // because want a short cut, but could be intermediate in Controller. Short cut are bad
15 // for UpdateIndicator, but should be partly in ControllerIndicatorFrame, partly in view ?
16 #include "../View/THStockFrame.h"
17 #include "../View/IndicatorFrame.h"
18 
19 #include "../../src_cpp/StockManager.h"
20 #include "../../src_cpp/Stock.h"
21 
22 // because ControllerBase is used here, need for sending something
23 // before get signaled, all hidden by ControllerBase
24 #include "../GUIMainController.h"
25 
26 #include "../GUIException.h"
27 // TransDateBox, but already from GUIException ??
28 #include "../TransientFrame.h"
29 
31  TGCompositeFrame * associated_frame, bool b_mainframe ) :
32  ControllerFrame<ControllerIndicatorTHStock>( parent_control, name_control )
33 {
34 #ifdef DEBUG_CONT_FRAME
35  std::cout << "Constructor MainControllerIndicatorTHStock name " << GetName() << std::endl;
36  std::cout << "associated/moteher_frame " << associated_frame << std::endl;
37  std::cout << "b_mainfrane " << b_mainframe << std::endl;
38 #endif
39 
40  // could be in sub-controller, no not needed in subcontroller
41  //fcurrent_indic_frame = 0;
42  //fcurrent_thstock_frame = 0;
43  // but need a current_controller
45 
46  //myparent_controller = (GUIMainController *)parent_control;
47  myparent_controller = parent_control;
48 
49  // initialize fstockmanger
50  // maybe better if stored in MainController, here need just a pointer to it
51  // avoid access to global from many instance
52  //fstockmanager = StockManager::getInstance(Utils::PATH_DATA);
53 
54  // create the graphic, strange use of associated frame...
55  // here create associated into fHframe0
56 
57  // set data member, is useful to know when it is created, without testing the parent
58  kMainFrame = b_mainframe;
59 
60  // creates a different main frame, multi-screen use
61  // b_mainframe is only a parameter here
62  // try to set a data_member, useful for any update of the parent
63  if ( b_mainframe ) {
64 #ifdef DEBUG_CONT_FRAME
65  std::cout << "Create an independent MainIndicatorTHStockFrame " << std::endl;
66 #endif
67  // do not associate to a parent frame, will be closed by CloseWindow
68  findic_thstock = new MainIndicatorTHStockFrame( 0, this, "MainIndicatorTHStockFrame", 120, 100 );
69 
70  // composite inside an other frame
71  } else {
72 #ifdef DEBUG_CONT_FRAME
73  std::cout << "Create an MainIndicatorTHStockFrame inside assoc_frame" << associated_frame << std::endl;
74 #endif
75  findic_thstock = new MainIndicatorTHStockFrame( associated_frame, this, "MainIndicatorTHStockFrame", 120, 100 );
76  // associate to the parent frame
77  associated_frame->AddFrame( findic_thstock,new TGLayoutHints( kLHintsLeft | kLHintsExpandX | kLHintsExpandY ,2,2,2,2) );
78  }
79 
80 #ifdef DEBUG_CONT_FRAME
81  std::cout << "After creation of MainIndicatorTHStockFrame this (MainController) " << this << std::endl;
82  // can try to Add now, not GUIMainController, or order is important ??
83  // change nothing if done here, work if done here, done from controller, equivalent ?? more freedom ??
84  //associated_frame->AddFrame( findic_thstock, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY ,2,2,2,2) );
85  std::cout << "created MainIndicatorTHStockFrame findic_thstock " << findic_thstock << std::endl;
86  std::cout << "set kMainFrame " << kMainFrame << std::endl;
87  std::cout << "End constructor MainControllerIndicatorTHStockFrame " << std::endl;
88 #endif
89 }
90 
92 #ifdef DEBUG_CONT_FRAME
93  std::cout << "Destructor MainControllerIndicatorTHStock delete sub-controllers " << std::endl;
94 #endif
95  // delete sub-controllers, will delete THstockFrame
96  DeleteList();
97  // reset pointer member ?
98  //delete findic_thstock; //crash later if delete
99  //findic_thstock = 0;
100  //myparent_controller = 0;
101  //fcurrent_controller = 0;
102 }
103 
105 {
107 }
114 {
115 #ifdef DEBUG_CONT_FRAME
116  std::cout << "\n\tEntry MainControllerIndicatorTHStock::AddCouple_Indicator_THStock frame_name " << frame_name << std::endl;
117  std::cout << "findic_thstock " << findic_thstock << std::endl;
118 #endif
119 
120  // To search if frame_name already exists or option force new...
121  //ControllerIndicatorTHStock *child_controller = FindByName
122 
123  // create a new controller and 2 new frames
124  //ControllerIndicatorTHStock *child_controller = new ControllerIndicatorTHStock( this, "IndicatorTHStock_1", frame_name );
125  ControllerIndicatorTHStock *child_controller = new ControllerIndicatorTHStock( this,
126  //findic_thstock->GetIndicatorFrame(), findic_thstock->GetTHStockFrame(), "IndicatorTHStock_1", frame_name );
128  // add the controller to the list
129  AddController( child_controller );
130 
131  // again put frame code in controller
132  // needed of independent frame
133  // Resize(); // not needed ??
134  // // only this is needed when independent frame
135  // MapWindow();
136  // solve problem independent frame, but problem with windows moving
137  GetFrame()->Resize();
138  GetFrame()->MapWindow();
139 
140  // in this implementation, all created from MainControllerIndicatorTHStock,
141  // more logic if moved in ControllerIndicatorTHStock. BUT
142  // BUT child controller would to access the parent findic_stock(a frame): GetParentFrame()->Add
143  /*
144  child_controller->SetIndicatorFrame( findic_thstock->AddIndicatorFrame( frame_name ) );
145  if ( child_controller->GetIndicatorFrame() == 0 )
146  std::cout << "\n\tError in MainControllerIndicatorTHStock::AddCouple_Indicator_THStock SetIndicatorFrame failed" << std::endl;
147 
148  child_controller->SetTHStockFrame( findic_thstock->AddTHStockFrame( frame_name ) );
149  if ( child_controller->GetTHStockFrame() == 0 )
150  std::cout << "Error in MainControllerIndicatorTHStock::AddCouple_Indicator_THStock SetTHStockFrame failed" << std::endl;
151  */
152  // set up as current_controller if a new added, VERY IMPORTANT !
153  fcurrent_controller = child_controller;
154  // and set up controller of the frame !
155  //child_controller->GetTHStockFrame()->SetController( child_controller );
156  // need the same for IndicatorFrame
157  //child_controller->GetIndicatorFrame()->SetController( child_controller );
158 
159 #ifdef DEBUG_CONT_FRAME
160  std::cout << "child_controller->GetIndicatorFrame() " << child_controller->GetIndicatorFrame() << std::endl;
161  std::cout << "child_controller->GetTHStockFrame() " << child_controller->GetTHStockFrame() << std::endl;
162  // equivalent fHSframe->GetList()->Print();
163  //std::cout << "findic_thstock->Print() " << std::endl;
164  //findic_thstock->Print();
165  //std::cout << "after findic_thstock->Print() " << std::endl;
166  //std::cout << "findic_thstock->GetIndicatorFrame()->Print() " << std::endl;
167  //findic_thstock->GetIndicatorFrame()->Print();
168 #endif
169 }
170 
172 {
174 }
175 
176 // Done by GUIMainController
177 //void MainControllerIndicatorTHStock::DeleteCouple_Indicator_THStock()
178 //{
179 // std::cout << "Entry MainControllerIndicatorTHStock::DeleteCouple_Indicator_THStock()" << std::endl;
180  // delete all sub-controllers ControllerIndicatorTHStock, will delete the frames
181  // already done in destructor
182  //DeleteList();
183 
184  // need to delete himself, call the parent
185  // could be in base class
186 // myparent_controller->RemoveController(this);
187 //}
188 
196 void MainControllerIndicatorTHStock::Validation( std::string fullname )
197 {
198 #ifdef DEBUG_CONT_FRAME
199  std::cout << "MainControllerIndicatorTHStock::Validation( fullname ) " << fullname << std::endl;
200 #endif
201 
202  // need to create a Controller as soon as possible
203  std::string frame_name;
205 
206 
207  // if cancelled pressed more explicit, to_insert to replace by cancel
208  //bool cancel;
209 
210  // need to know if stock exists or not in the stock
211  // more general if done in StockManager and Stock
212  //bool insert_new_stock;
213  bool to_insert;
214 
215  // need to insert
216  //StockManager *fstockmanager = myparent_controller->GetStockManager();
217  StockManager *fstockmanager = GetStockManager();
218 
219  // extract data from the fullname
220  std::string namestock = FullName::GetNameStock( fullname );
221  ETime tmscl = FullName::GetTimeScale( fullname );
222  Indicator indic = FullName::GetIndicator( fullname );
223  std::vector<int> vec_param = FullName::GetParams( fullname );
224 
225  // create the frame name
226  //frame_name = namestock+'_'+TimeScale::GetTimeScaleName( tmscl );
227  frame_name = FrameName::MakeFrameName( namestock, tmscl );
228 
229 #ifdef DEBUG_CONT_FRAME
230  std::cout << "extracted namestock " << namestock << std::endl;
231  std::cout << "new created frame_name " << frame_name << std::endl;
232 #endif
233 
234  /*
235  // get a valid stock, new one or existing
236  // Check if the stock is already present, what about timescale, maybe dcsv is loaded, not DAY ?
237  Stock *tmp_stock = fstockmanager->Find( namestock );
238  // set insert_new_stock true if a new one is created
239  if ( tmp_stock == 0 ) {
240 #ifdef DEBUG_CONT_FRAME
241  std::cout << "namestock " << namestock << "is not loaded " << std::endl;
242 #endif
243  tmp_stock = new Stock( namestock, namestock, Utils::PATH_DATA );
244  //insert_new_stock = true;
245  } else {
246  std::cout << "MainControllerIndicatorTHStock::Validation stock already exists " << std::endl;
247  }
248 */
249  // now can decide which dates to load when reading from file
250  // should be asked as well if WEEK/MONTH because can update the data with the parser
251  // even H1, M5 makes sense to discard all previous days
252  if ( ( ( indic == Indicator::StockCSV ) || ( indic == Indicator::StockInst ) ) &&
253  ( ( tmscl == ETime::DAY ) || ( tmscl == ETime::INST ) ) ) {
254 
255  // here bad, modified by TransFrame anyway, it is the cancel button
256  //bool to_insert = true; //false;
257 
258  // make a tmp_stock to access Read_Header, send to the TransFrame or make a static version
259  // here real object useful, can query Python with it
260  fstockmanager->PrintMap();
261 
262  // Check if the stock is already present, what about timescale, maybe dcsv is loaded, not DAY ?
263  Stock *tmp_stock = fstockmanager->Find( namestock );
264 
265  // set insert_new_stock true if a new one is created
266  if ( tmp_stock == 0 ) {
267 #ifdef DEBUG_CONT_FRAME
268  std::cout << "namestock " << namestock << "is not loaded " << std::endl;
269 #endif
270  tmp_stock = new Stock( namestock, namestock, Utils::GetPathData() );
271  //insert_new_stock = true;
272 
273  } else {
274  std::cout << "MainControllerIndicatorTHStock::Validation Should check than the indicator is not loaded as well " << std::endl;
275  // different choices, reload or quit...
276  }
277 
278  // check if the file exists and read the date indicated in the header
279  try {
280  tmp_stock->Read_HeaderCSV ( tmscl, transdata_date );
281 
282  // try the base class, works, better with the full message
283  } catch ( const StockException & e ) {
284 #ifdef DEBUG_CONT_FRAME
285  std::cout << "Caught StockException from Read_HeaderCSV" << std::endl;
286  std::cout << "Message e.what: " << e.what() << std::endl;
287 #endif
288  delete tmp_stock;
289  tmp_stock = 0;
290  // transform to GUIStockException for generality in GUIStock
291  throw ( GUIStockException ( e ) );
292  }
293 
294  // should load data or not, here or later when updated
295 #ifdef DEBUG_CONT_FRAME
296  std::cout << "\n\tbefore TransDataBox transdata " << transdata_date.first << " " << transdata_date.last << std::endl;
297 #endif
298  // ok already constructed findic_stock
299  //std::cout << "findic_thstock " << findic_thstock << std::endl;
300 
301  // data are loaded inside the frame
302  try {
303  new TransDateBox(gClient->GetRoot(), findic_thstock, tmp_stock,
304  tmscl, indic, transdata_date, &to_insert );
305  } catch ( const GUIException & e ) {
306 #ifdef DEBUG_EXCEPT
307  std::cout << "Caught a GUIException from TransDateBox " << std::endl;
308 #endif
309  } catch ( const std::exception & e ) {
310  std::cout << "From Controller get a base std::exception " << std::endl;
311  }
312  //std::cout << "after TransDataBox " << std::endl;
313  // how valid ? it has been destroyed
314 #ifdef DEBUG_CONT_FRAME
315  std::cout << "after TransDataBox " << transdata_date.first << " " << transdata_date.last << std::endl ;
316  std::cout << "to_insert " << to_insert << std::endl;
317  std::cout << "\n\tafter TransDataBox " << transdata_date.first << " " << transdata_date.last << std::endl ;
318 #endif
319 
320  // 13/02/2013 crash on gigantes
321  tmp_stock->PrintMapChrono();
322 
323  // to delete, but should take care of what happens to the pointer
324  //delete tmp_stock;
325  //tmp_stock = 0;
326  //exit(1);
327 
328  // if cancel delete the stock. not sure which again which one...
329 
330  // wrong test, to_insert corresponds to the cancel button, to_insert = true if valid
331  if ( to_insert ) {
332  //if ( (insert_new_stock == true) && (cancel == false ) ) {
333 #ifdef DEBUG_CONT_FRAME
334  std::cout << "insert_new_stock true, call StockManager->Load()" << std::endl;
335 #endif
336  // return nothing, no exception no error, should improve
337  // at least a return 0
342  //try {
343  fstockmanager->AddStock( tmp_stock );
344  //} catch (StockException & e){
345  // stock to delete
346  // throw (GUIStockException(e));
347  //}
348  // here delete tmp_stock if insertion is bad
349  // if cancel nothing to do ( or error in implementation
350  } else {
351  delete tmp_stock;
352  tmp_stock = 0;
353  return;
354  }
355  // not used anymore : inserted or deleted.
356  tmp_stock = 0;
357 
358  } // end if use TransDateBox
359 
360  // else other indicator / timescale no transient frame to create
361  else {
362 #ifdef DEBUG_CONT_FRAME
363  std::cout << "Load directly without transient frame" << std::endl;
364 #endif
365  // now need to insert stock into StockManager
366  // because sure there is something to add
367  try {
368  fstockmanager->Load( namestock, tmscl, indic, vec_param, transdata_date );
369 
370  // ok works, get a StockException if Valid with bad stock
371  } catch ( const StockException & e ) {
372 #ifdef DEBUG_EXCEPT
373  std::cout << "\nMainController Catch a StockException " << std::endl;
374  std::cout << "e.what() " << e.what() << std::endl;
375 #endif
376  throw ( GUIStockException( e ) );
377  }
378  } // end if transient frame to query for dates or not
379 
380  // if here no exception thrown, all fine
381 #ifdef DEBUG_CONT_FRAME
382  fstockmanager->PrintMap();
383 #endif
384  // end of check for data to load, should call, MainControllerIndicatorTHStock
385  // here really job of controller, for the moment, to Add ToAddMainFrame ( TGMainFrame )
386 #ifdef DEBUG_CONT_FRAME
387  std::cout << " findic_thstock->ToAddCanvas() " << findic_thstock->ToAddCanvas() << std::endl;
388  std::cout << " findic_thstock->ToMakeMain() " << findic_thstock->ToMakeMain() << std::endl;
389  // to check if one controller is already created and selected
390  //std::cout << " findic_thstock->GetFrameCurrent() " << findic_thstock->GetFrameCurrent() << std::endl;
391  std::cout << " fcurrent_controller " << fcurrent_controller << std::endl;
392 #endif
393 
395 
396  if ( findic_thstock->ToMakeMain() ) {
397 #ifdef DEBUG_CONT_FRAME
398  std::cout << "ToMakeMain " << std::endl;
399 #endif
400  // new to create a new MainController empty, no data
401  //AddCouple_Indicator_THStock( frame_name );
402  //myparent_controller->CreateMainControllerIndicatorTHStock( true );
403 
404  // if a main is asked, call parent GUIMainController to create it
406  // the new controller should create its own frames and add the new data
407  //std::cout << "/n Call AddCouple_Indicator_THStock /n" << std::endl;
408  new_control->AddCouple_Indicator_THStock( frame_name );
409 
410  // AddData should be in ControllerIndicatorTHStock
411  new_control->GetCurrentController()->AddData( fullname );
412 
413  // could be common function, FinalizeFrame ( different pointer... )
414  // finalize the other object, make same before return
415  // copy what was done if not main
416  new_control->GetFrame()->MapSubwindows();
417  new_control->GetFrame()->Resize();
418  new_control->GetFrame()->MapWindow();
419 
420  // reset check button, work as expected after MapSubWindows
421  new_control->GetFrame()->ResetEntries();
422  // should return now, we are dealing with an other object !
423  return;
424  }
425 
427  else if ( findic_thstock->ToAddCanvas() || ( fcurrent_controller == 0 ) ) {
428 #ifdef DEBUG_CONT_FRAME
429  std::cout << "ToAddCanvas() CreateCouple Indicator " << std::endl;
430 #endif
431  // call function to create 1 ControllerIndicatorTHStock
432  AddCouple_Indicator_THStock( frame_name );
433  }
434 
436 #ifdef DEBUG_CONT_FRAME
437  else {
438  std::cout << "Current controller is already setup " << fcurrent_controller << std::endl;
439  }
440 #endif
441 
443 
444  // in all cases Add the data
445  fcurrent_controller->AddData( fullname );
446  // update the indicator
447  findic_thstock->MapSubwindows();
448  // resize necessary, otherwise indicator bad shown, validated
449  findic_thstock->Resize();
450 #ifdef DEBUG_CONT_FRAME
451  std::cout << "Before UpdateGUIFromController UpdateGUIFromController" << std::endl;
452 #endif
453 
454  // here finalize the update of the main/first GUIMainFrame
455  // now is maybe TGMainFrame, maybe do not need
456  //std::cout << " I am not a mainframe, I update my parent frame " << std::endl;
457  // necessary for resizing
459 
460  // reset entries here, seems working but crash ! due to here ??
461  // fine when done at the end
462  GetFrame()->ResetEntries();
463 }
464 
465 void MainControllerIndicatorTHStock::Updated( std::vector<std::string> & message )
466 {
467 #ifdef DEBUG_CONT_FRAME
468  std::cout << "Entry MainControllerIndicatorTHStock::Updated " << std::endl;
469 #endif
470  // get the list of stuffs for the list, not here
471  // do the same, just broadcast here. Can decide ??
472  // here no need to test the message if everything is send
473  // only one, but keep it here
474  if ( message[0] == "update_dcsv" ) {
475 
476  for ( it_list it = list_controller.begin(); it != list_controller.end(); ++it ) {
477  // test if special ! CAC40 & DJ, but lots of work to implement
478  // inside ! not here
479  (*it)->Updated( message );
480  }
481 
482  } else {
483  std::cout << "Message MainControllerIndicatorTHStock::Updated not known message " << message[0] << std::endl;
484  }
485 }
486 
489 {
490 #ifdef DEBUG_CONT_FRAME
491  std::cout << "\n\tEntry MainControllerIndicatorTHStock::GetSelected child_control " << child_controller << std::endl;
492  std::cout << "child_controller->GetName() " << child_controller->GetName() << std::endl;
493 #endif
494 
495  // coming from its child current frame always the same
496  fcurrent_controller = child_controller;
497 
498  //Fill with good name in toolbar, still to redo
499  std::string namestock = FullName::GetNameStock ( fcurrent_controller->GetName() );
501 
502  // function to setup correctly the text boxes
503  findic_thstock->SetTextResearch ( namestock );
504  findic_thstock->SetTimeScale ( (int)timescale );
505 }
506 
509 // could regroup everything here as well...
511 {
512 #ifdef DEBUG_CONT_FRAME
513  std::cout << "Entry MainControllerIndicatorTHStock::UpdateIndicator mode " << mode << std::endl;
514 #endif
515 
516  if ( ( mode == "DELETE_ALL" ) || ( mode == "HIDE_ALL" ) ) {
517  //std::cout << "In Update mode DELETE_ALL or HIDE_ALL frame_name " << frame_name << std::endl;
518  // do not care about the name
519 #ifdef DEBUG_CONT_FRAME
520  std::cout << "In Update mode DELETE_ALL or HIDE_ALL " << std::endl;
521 #endif
522  //std::cout << "IsVisible " << findic_thstock->GetTHStockFrame()->IsVisible( child_controller->GetTHStockFrame() ) << std::endl;
523  findic_thstock->GetTHStockFrame()->HideFrame( child_controller->GetTHStockFrame() );
524  // Indicator already hidden/deleted
525 
526  // delete one full CanvasStock
527  if (mode == "DELETE_ALL" ) {
528 #ifdef DEBUG_CONT_FRAME
529  std::cout << " DELETE_ALL " << std::endl;
530 #endif
531  // delete THStockFrame and Embedded CanvasStock
532  // could be in a function DeleteChildController, a part in ChildController as well
533  findic_thstock->GetTHStockFrame()->RemoveFrame( child_controller->GetTHStockFrame() );
534  delete child_controller->GetTHStockFrame();
535  child_controller->SetTHStockFrame(0);
536 
537  // problem because called from IndicatorFrame ? then come back, strange
538  findic_thstock->GetIndicatorFrame()->RemoveFrame( child_controller->GetIndicatorFrame() );
539  delete child_controller->GetIndicatorFrame();
540  child_controller->SetIndicatorFrame(0);
541 
542  // kill the controller
543  RemoveController( child_controller );
544  delete child_controller;
545  // here should point to another
546  // try to point to the first in list
547  //std::cout << " GetSizeListController " << GetSizeListController() << std::endl;
548  if ( GetSizeListController() > 0 ) {
550  std::cout << "Reset current_controller to the first " << fcurrent_controller->GetName();
551  } else {
553  }
554 #ifdef DEBUG_CONT_FRAME
555  std::cout << " After DELETE_ALL " << std::endl;
556  std::cout << " current_controller " << fcurrent_controller << std::endl;
557 #endif
558  }
559  } else if ( mode == "SHOW_ALL" ) {
560 #ifdef DEBUG_CONT_FRAME
561  std::cout << " Update mode SHOW_ALL " << std::endl;
562 #endif
563  findic_thstock->GetTHStockFrame()->ShowFrame( child_controller->GetTHStockFrame() );
564  } else {
565  std::cout << "\n\tError mode not known in MainControllerIndicatorTHStock::UpdateIndicator mode !!\n" << mode << std::endl;
566  }
567  //findic_thstock->Resize();
569 }
570 
572 {
573 #ifdef DEBUG_CONT_FRAME
574  std::cout << "Entry MainControllerIndicatorTHStock::Update" << std::endl;
575 #endif
576  // here should propagate to all sub-controllers !!
577  // not only the current one
579 }
580 
581 
Singleton class, stores all loaded stocks.
Definition: StockManager.h:42
MainControllerIndicatorTHStock(GUIMainController *parent_control, std::string name, TGCompositeFrame *associated_frame, bool b_mainframe)
Constructor.
void SetTextResearch(std::string new_text)
need for controller to set up
std::string MakeFrameName(const std::string &namestock, const ETime &tmscl)
Create a frame name string from its components.
Definition: FullName.cpp:128
std::list< ControllerIndicatorTHStock * > list_controller
list more convenient, remove if not shown ?, or insert
Definition: Controller.h:108
Controller for a dual frame containing Indicator+THStock(s).
"Clever" enumeration of the ListDataStock type : StockCSV, Volume, EMA, BOLL,...
Definition: Indicator.h:29
void ResetEntries()
reset all widget entries, may add options
bool kMainFrame
link to StockManager, singleton, initialized in constructor
void UpdateGUIFromController()
only gui_mainframe->Resize(), but seems necessary when a new frame created
Main controller of the application, linked to the view GUIMainFrame.
void AddController(ControllerIndicatorTHStock *control)
Common Function for dealing with the list, need a name, may call other controllers...
Definition: Controller.h:134
virtual const char * what() const noexcept
virtual void DeleteList(bool call_delete=true)
Iterative call for deleting child controller.
Definition: Controller.h:163
virtual unsigned int GetSizeListController() const
Definition: Controller.h:186
MainIndicatorTHStockFrame * findic_thstock
void DeleteIndicatorTHstock()
Delete all couples of frames and thstocks Call by MainControllerIndicatorStock::CloseWindow() ...
Final controller class, does not derive from ListController.
ControllerIndicatorTHStock * fcurrent_controller
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())
Load a specific ListDataStock.
std::list< ControllerIndicatorTHStock * >::iterator it_list
useful typedef for the class ( and derivatives !)
Definition: Controller.h:110
bool ToAddCanvas()
check state of button
Base Exception for Stock and StockManager, all src_cpp code.
std::string GetNameStock(const std::string &fname)
Extract the name of the stock.
Definition: FullName.cpp:46
Main class to deal with one stock.
Definition: Stock.h:56
void DeleteControllerIndicatorTHStock(MainControllerIndicatorTHStock *control)
MainIndicatorTHStockFrame * GetFrame() const
Sub-controller : assure drawing and coupling of 1 IndicatorFrame and 1 THStock.
virtual void Updated(std::vector< std::string > &message)
Call by parent controller, when a new message is available.
TGHorizontalFrame * GetTHStockFrame() const
void SetTHStockFrame(THStockFrame *fthstock)
MainControllerIndicatorTHStock * CreateMainControllerIndicatorTHStock(bool kmain=false)
Creates child controllers, contains Indicator+THStock(s).
Indicator GetIndicator(const std::string &fname)
Extract the Indicator from a fullname.
Definition: FullName.cpp:59
ControllerIndicatorTHStock * GetFirstController()
get the first controller in list, useful after a delete
Definition: Controller.h:158
void SetIndicatorFrame(IndicatorFrame *findic)
ETime
Enumeration for the different time representation, from instantaneous (INST) to year(YEAR) ...
Definition: TimeScale.h:48
std::string GetName() const
Definition: Controller.h:66
static Indicator const StockInst
Definition: Indicator.h:44
void GetSelected(ControllerIndicatorTHStock *child_controller)
receive indirectly the IndicatorFrame Selected, can set the current_frame ( can get pad also ) ...
void AddData(std::string fullname)
Used when a new ListData is added, need SM access here, or in parent...
Frame contains Indicator and THStock.
TGVerticalFrame * GetIndicatorFrame() const
get the important child frames for drawing
void Update()
coming from StockManager, through observer pattern no should come from gui_maincontroller now ...
std::string GetPathData()
Definition: Utils.cpp:42
void UpdateIndicator(ControllerIndicatorTHStock *child_controller, std::string mode)
called by controller child for some tasks child cannot do.
Stock * Find(const std::string &namestock) const
Retrieve an instance of a stock.
void AddCouple_Indicator_THStock(std::string frame_name)
Create a new sub-controller and update views for adding a new frame Does not add any data...
void Validation(std::string fullname)
Load stock or indicator after pressing the Validation button.
static Indicator const StockCSV
Definition: Indicator.h:44
GUIMainController * GetGUIMainController() const
ControllerIndicatorTHStock * GetCurrentController() const
Base class, for all gui errors Need a real base class here, or just use directly StockException.
Definition: GUIException.h:49
void PrintMapChrono(const unsigned int verbose=0) const
Print map content to the console.
Definition: Stock.cpp:2127
static SUPPRESS_NOT_USED_WARN firstlast_dates get_fldate_default()
need to be static for using default argument in a function
Definition: Utils.h:60
void UpdateFrames()
keep only for updating THStockFrame for the moment, how done by Indicator ?
void RemoveController(ControllerIndicatorTHStock *control)
Definition: Controller.h:139
int Read_HeaderCSV(ETime tmscl, Utils::firstlast_dates &dates) const
Read the dates from the header file.
Definition: Stock.cpp:1487
see remark below, much easier if composition than derivation in the case of ListController, same for parent_controller as member <U> easily extends to View as well ( ListView possible ), but strong coupling again
Definition: Controller.h:209
THStockFrame * GetTHStockFrame() const
general structure for dates in csv files
Definition: Utils.h:54
StockManager * GetStockManager() const
needed here
int AddStock(Stock *)
Add a stock to the stockmanager.
void PrintMap()
Print an user-friendly view of the StockManger content.
std::vector< int > GetParams(const std::string &fname)
Extract params from a fullname.
Definition: FullName.cpp:65
IndicatorFrame * GetIndicatorFrame() const
ETime GetTimeScale(const std::string &fname)
Extract the TimeScale from a fullname.
Definition: FullName.cpp:53