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 Attributes | Friends
MultiData Class Reference

Generalisation of SimpleData, contains a vector of type_value_data values. More...

#include <DataStock.h>

Inheritance diagram for MultiData:
Inheritance graph
[legend]
Collaboration diagram for MultiData:
Collaboration graph
[legend]

Public Member Functions

 MultiData ()
 Default constructor, set number of data to 1 and a default value of 0. More...
 
 MultiData (unsigned int nbdata)
 Set the size of the vector, fill with 0. More...
 
 MultiData (time_t d, std::vector< type_value_data > ivalues)
 Set date and copy the vector given as parameter. More...
 
 MultiData (const MultiData &rhs)
 Copy constructor. More...
 
 MultiData (MultiData &&rhs)
 Move copy constructor. More...
 
virtual ~MultiData ()
 
Assignment operators
MultiDataoperator= (const MultiData &rhs)
 Normal assignment. More...
 
MultiDataoperator= (MultiData &&rhs)
 Move assignment. More...
 
Implementation of pure virtual functions for MultiData
void SetData (const time_t d, const std::vector< type_value_data > &vec)
 Set a full Data : date + value(s) in a vector. More...
 
virtual std::vector
< type_value_data
GetValues () const
 Return the value(s) in a vector. More...
 
void SetValues (std::vector< type_value_data > &vec)
 Set only values, do not modify the date. More...
 
virtual type_value_data GetMaximum () const
 Get the maximum value. More...
 
virtual type_value_data GetMinimum () const
 Get the minimum value. More...
 
virtual bool HasChanged (const DataStock &data_to_check) const
 Check if data are different. More...
 
virtual void ExtractCSVLine (std::vector< std::string > &linecsv)
 Extract date and data from a split string. More...
 
void PrintData (const unsigned int verbose=0) const
 User friendly output on screen. More...
 
- Public Member Functions inherited from DataStock
 DataStock ()
 Default constructor set date to 0. More...
 
 DataStock (time_t d)
 Set the date, used in initialization of derived classes. More...
 
 DataStock (const DataStock &rhs)
 Copy constructor. More...
 
 DataStock (DataStock &&rhs)
 Move copy constructor. More...
 
virtual ~DataStock ()
 Destructor. More...
 
DataStockoperator= (const DataStock &rhs)
 Normal assignment. More...
 
DataStockoperator= (DataStock &&rhs)
 Move assignment. More...
 
time_t GetDate () const
 Get the date data member. More...
 
void SetDate (const time_t d)
 Modify the date. More...
 
std::string GetDateString (const bool bhours=true) const
 Return the date in a string format: "YEAR-MOnth-DAy HH:MM:SS" (2014-11-10 13::25::00) More...
 
struct tm GetDateTm () const
 Get a tm structure of the date. More...
 

Protected Member Functions

Specific to input/output of MultiData
virtual void helper_operator_write (std::ostream &os) const
 
virtual void helper_operator_read (std::iostream &ios)
 
- Protected Member Functions inherited from DataStock
int helper_operator_read_base (std::iostream &ios)
 Helper function for operator<< for reading date from input streams. More...
 
void helper_operator_write_base (std::ostream &os) const
 Helper function for operator>> for writing date to output. More...
 

Private Attributes

const unsigned int nb_data
 Number of data stored in the vector. More...
 
std::vector< type_value_datavalues
 Vector for storing values. More...
 

Friends

bool operator== (const MultiData &lhs, const MultiData &rhs)
 

Additional Inherited Members

- Protected Attributes inherited from DataStock
time_t date
 All data have a date associated. More...
 

Detailed Description

Generalisation of SimpleData, contains a vector of type_value_data values.


Used for indicators with multiple data, e.g., MACD, BOLL...
Once the object is created the size of the vector is fixed
It cannot be extended during the life time of the object (use of const nb_data as data member).

Definition at line 432 of file DataStock.h.

Constructor & Destructor Documentation

MultiData::MultiData ( )

Default constructor, set number of data to 1 and a default value of 0.

Definition at line 398 of file DataStock.cpp.

References values.

MultiData::MultiData ( unsigned int  nbdata)

Set the size of the vector, fill with 0.

Definition at line 412 of file DataStock.cpp.

References nb_data, and values.

MultiData::MultiData ( time_t  d,
std::vector< type_value_data ivalues 
)

Set date and copy the vector given as parameter.

Definition at line 423 of file DataStock.cpp.

MultiData::MultiData ( const MultiData rhs)

Copy constructor.

Definition at line 432 of file DataStock.cpp.

References nb_data, and values.

MultiData::MultiData ( MultiData &&  rhs)

Move copy constructor.

Definition at line 445 of file DataStock.cpp.

References values.

virtual MultiData::~MultiData ( )
inlinevirtual

Definition at line 453 of file DataStock.h.

Member Function Documentation

void MultiData::ExtractCSVLine ( std::vector< std::string > &  vec)
virtual

Extract date and data from a split string.

Deprecated:
keep only for test performance comparison. Use operators<< >> now.
Parameters
vecvector of string containing the date and the value(s)

Implements DataStock.

Definition at line 562 of file DataStock.cpp.

References nb_data, SetData(), and Utils::StringToTime_t().

Here is the call graph for this function:

type_value_data MultiData::GetMaximum ( ) const
virtual

Get the maximum value.

Implements DataStock.

Definition at line 504 of file DataStock.cpp.

References values.

type_value_data MultiData::GetMinimum ( ) const
virtual

Get the minimum value.

Implements DataStock.

Definition at line 516 of file DataStock.cpp.

References values.

std::vector< type_value_data > MultiData::GetValues ( ) const
virtual

Return the value(s) in a vector.

Implements DataStock.

Definition at line 529 of file DataStock.cpp.

References values.

Referenced by HasChanged().

Here is the caller graph for this function:

bool MultiData::HasChanged ( const DataStock data_to_check) const
virtual

Check if data are different.

To compare all fields use operator==
Exact implementation is different for each derived class:

Todo:
check why DataCSV compares dates also, not the others why not use == now
case of double dispatching for DataCSV when compared with SimpleData, makes more general ?
Returns
true if values are considered different

Implements DataStock.

Definition at line 544 of file DataStock.cpp.

References DataStock::GetValues(), GetValues(), and nb_data.

Here is the call graph for this function:

MultiData & MultiData::operator= ( const MultiData rhs)

Normal assignment.

Size of the vector should be equal, enforced by assert

Definition at line 461 of file DataStock.cpp.

References nb_data, DataStock::operator=(), and values.

Here is the call graph for this function:

MultiData & MultiData::operator= ( MultiData &&  rhs)

Move assignment.

Definition at line 484 of file DataStock.cpp.

References DataStock::operator=(), and values.

Here is the call graph for this function:

void MultiData::PrintData ( const unsigned int  verbose = 0) const
virtual

User friendly output on screen.

verbose level:

  • 0 : default, print all data in one line, format with comma
  • 1 : add a header before the line

    Parameters
    verboselevel of output

Implements DataStock.

Definition at line 582 of file DataStock.cpp.

References FDS::WCOL.

void MultiData::SetData ( const time_t  d,
const std::vector< type_value_data > &  vec 
)
inlinevirtual

Set a full Data : date + value(s) in a vector.

Implements DataStock.

Definition at line 467 of file DataStock.h.

References DataStock::date, and values.

Referenced by ExtractCSVLine().

Here is the caller graph for this function:

void MultiData::SetValues ( std::vector< type_value_data > &  )
virtual

Set only values, do not modify the date.

Implements DataStock.

Definition at line 534 of file DataStock.cpp.

References nb_data, and values.

Referenced by helper_operator_read().

Here is the caller graph for this function:

Friends And Related Function Documentation

bool operator== ( const MultiData lhs,
const MultiData rhs 
)
friend

Definition at line 916 of file DataStock.cpp.

Field Documentation

const unsigned int MultiData::nb_data
private

Number of data stored in the vector.

Because of const specifier cannot be changed during the life time of the object

Definition at line 437 of file DataStock.h.

Referenced by ExtractCSVLine(), HasChanged(), helper_operator_read(), helper_operator_write(), MultiData(), operator=(), and SetValues().

std::vector<type_value_data> MultiData::values
private

Vector for storing values.

Definition at line 440 of file DataStock.h.

Referenced by GetMaximum(), GetMinimum(), GetValues(), helper_operator_write(), MultiData(), operator=(), operator==(), SetData(), and SetValues().


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