ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Indicator.h
Go to the documentation of this file.
1 
8 #ifndef INDICATOR_H_
9 #define INDICATOR_H_
10 
11 
12 #include <iostream>
13 #include <vector>
14 
15 // Note : Using the option --short-enums of GCC, that makes it use the smallest type still fitting all the values.
16 // by default found sizeof(4), to do, try the option
17 
29 class Indicator {
30 
31 private:
32 
35 
37 
38  Value FindValue(std::string) const;
39 
40 public:
41 
43  // must be public
45 
49  Indicator (Value v): v_ (v) {}
50 
51  // a bit unclear, it is not a constructor, but could be Indicator(string label), better ?? certainly but many changes in code !
52  // to see with unit_test
57  static Indicator GetIndicator(const std::string& str_name );
59 
63  std::string const label () const;
65  static std::vector<std::string> GetListAllIndicator();
66 
68  int nb_param () const;
70  int nb_input() const;
72  int nb_output () const;
74  bool HasDefaultValues() const;
76  std::vector<int> GetDefaultValues() const;
78  std::string GetDescription() const;
80  std::vector<std::string> parse_description() const;
81 
82  // test to know what should be called
83  // first basic test, later add a field in indicator
85  bool NeedToComputeTA() const;
86 
87  //cannot be const because we set the correct indicator from the string
88  // what is the point ? params never saved in Indicator, maybe later ??
89  // to comment
90  void Set( std::string str_name, std::vector<int> & param );
91 
92  // From character B,R,V to integer of color
93  // used in FactoryMethod,
94  int MakeEColor( const char str_color);
95  // used to set color in label from palette
96  int MakeColor( const char str_color);
97 
99  // test to modify array ! ok works, can register the types on the fly
100  void Change( int new_value );
101 
103  // if C++11 enumeration need an explicit cast
104  Value integral () const {return v_;}
105 
108  friend bool operator== (Indicator const& a, Indicator const& b)
109  { return a.v_ == b.v_; }
110 
111  friend bool operator!= (Indicator const& a, Indicator const& b)
112  { return a.v_ != b.v_; }
114  friend std::ostream& operator<< (std::ostream& o, Indicator c);
116 
117 };
118 
119 #endif /* INDICATOR_H_ */
Value FindValue(std::string) const
Definition: Indicator.cpp:204
friend std::ostream & operator<<(std::ostream &o, Indicator c)
Output the label.
Definition: Indicator.cpp:298
static Indicator const STOCHF
Definition: Indicator.h:44
std::vector< std::string > parse_description() const
Utility function to parse the description.
Definition: Indicator.cpp:112
static std::vector< std::string > GetListAllIndicator()
Get a list of all indicator's label.
Definition: Indicator.cpp:57
"Clever" enumeration of the ListDataStock type : StockCSV, Volume, EMA, BOLL,...
Definition: Indicator.h:29
int nb_param() const
Nb of parameters necessary to be computed.
Definition: Indicator.cpp:68
void Set(std::string str_name, std::vector< int > &param)
Definition: Indicator.cpp:304
bool HasDefaultValues() const
Test functions if default values are provided.
Definition: Indicator.cpp:83
static Indicator const Null
Predefined static instances of the class.
Definition: Indicator.h:44
static Indicator const WMA
Definition: Indicator.h:44
Indicator(Value v)
Constructors.
Definition: Indicator.h:49
int MakeEColor(const char str_color)
Definition: Indicator.cpp:351
bool NeedToComputeTA() const
Test function if this indicator is computed with TALib interface.
Definition: Indicator.cpp:192
static Indicator const MACD
Definition: Indicator.h:44
static Indicator const AD
Definition: Indicator.h:44
static Indicator const RSI
Definition: Indicator.h:44
static Indicator GetIndicator(const std::string &str_name)
Constructor with a string label.
Definition: Indicator.cpp:234
int MakeColor(const char str_color)
Definition: Indicator.cpp:362
static Indicator const Volume
Definition: Indicator.h:44
int nb_output() const
Nb of ListDataStock output of TALib computation.
Definition: Indicator.cpp:78
void Change(int new_value)
Definition: Indicator.cpp:373
static Indicator const StockInst
Definition: Indicator.h:44
Value v_
Definition: Indicator.h:36
friend bool operator!=(Indicator const &a, Indicator const &b)
Definition: Indicator.h:111
static Indicator const EMA
Definition: Indicator.h:44
Value
Internally define an enumeration.
Definition: Indicator.h:34
static Indicator const StockCSV
Definition: Indicator.h:44
int nb_input() const
Nb of ListDataStock input to be computed.
Definition: Indicator.cpp:73
static Indicator const BOLL
Definition: Indicator.h:44
std::string GetDescription() const
Graphical description.
Definition: Indicator.cpp:102
std::vector< int > GetDefaultValues() const
Get the default values, return an empty vector if none are provided.
Definition: Indicator.cpp:88
static Indicator const SMA
Definition: Indicator.h:44
friend bool operator==(Indicator const &a, Indicator const &b)
Definition: Indicator.h:108
std::string const label() const
Get the label.
Definition: Indicator.cpp:51
Value integral() const
To use in the case of a switch.
Definition: Indicator.h:104