ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Protected Member Functions | Protected Attributes
DataStock Class Referenceabstract

Abstract base class for all Data to be stored in ListDataStock. More...

#include <DataStock.h>

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

Public Member Functions

Constructors and destructor
 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...
 
Assignment operators
DataStockoperator= (const DataStock &rhs)
 Normal assignment. More...
 
DataStockoperator= (DataStock &&rhs)
 Move assignment. More...
 
Not virtual functions, act only on dates
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...
 
Pure virtual functions
virtual void SetData (const time_t d, const std::vector< type_value_data > &vec)=0
 Set a full Data : date + value(s) in a vector. More...
 
virtual std::vector
< type_value_data
GetValues () const =0
 Return the value(s) in a vector. More...
 
virtual void SetValues (std::vector< type_value_data > &)=0
 Set only values, do not modify the date. More...
 
virtual type_value_data GetMaximum () const =0
 Get the maximum value. More...
 
virtual type_value_data GetMinimum () const =0
 Get the minimum value. More...
 
virtual bool HasChanged (const DataStock &data_to_check) const =0
 Check if data are different. More...
 
virtual void ExtractCSVLine (std::vector< std::string > &vec)=0
 Extract date and data from a split string. More...
 
virtual void PrintData (const unsigned int verbose=0) const =0
 User friendly output on screen. More...
 
Pure virtual helper functions for operator << and >>
virtual void helper_operator_write (std::ostream &os) const =0
 
virtual void helper_operator_read (std::iostream &ios)=0
 

Protected Member Functions

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...
 

Protected Attributes

time_t date
 All data have a date associated. More...
 

Friends

Friend operators for input/output.

The functions allow to combine DataStocks and use pointer or reference to the base class.

More description of their usage in this link

std::ostream & operator<< (std::ostream &os, const DataStock &obj)
 Fill ostream ( ostringstream ) with text data
. More...
 
std::iostream & operator>> (std::iostream &ios, DataStock &obj)
 Set a DataStock(s) with data from a iostream( e.g.,stringstream )
. More...
 
std::string & operator<< (std::string &line_csv, const DataStock &obj)
 Similar operator, but for use with string as output. More...
 
std::string & operator>> (std::string &line_csv, DataStock &obj)
 Similar operator, but can use string as input. More...
 

Detailed Description

Abstract base class for all Data to be stored in ListDataStock.

Define a common time_t date (and associated methods) for all subclasses and pure virtual function to override

Definition at line 90 of file DataStock.h.

Constructor & Destructor Documentation

DataStock::DataStock ( )

Default constructor set date to 0.

Definition at line 84 of file DataStock.cpp.

DataStock::DataStock ( time_t  d)

Set the date, used in initialization of derived classes.

Definition at line 90 of file DataStock.cpp.

DataStock::DataStock ( const DataStock rhs)

Copy constructor.

Definition at line 98 of file DataStock.cpp.

References date.

DataStock::DataStock ( DataStock &&  rhs)

Move copy constructor.

Definition at line 107 of file DataStock.cpp.

References date.

virtual DataStock::~DataStock ( )
inlinevirtual

Destructor.

Definition at line 111 of file DataStock.h.

Member Function Documentation

virtual void DataStock::ExtractCSVLine ( std::vector< std::string > &  vec)
pure 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)

Implemented in DataCSV, MultiData, and SimpleData.

time_t DataStock::GetDate ( ) const
inline
std::string DataStock::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)

by default only "YEAR-MOnth-DAy"

Parameters
bhoursoptional boolean, true will include "HH:MM:SS"
Returns
formatted string

Definition at line 164 of file DataStock.cpp.

References date, and Utils::Time_tToString().

Referenced by SimpleData::HasChanged(), DataCSV::HasChanged(), and helper_operator_write_base().

Here is the call graph for this function:

Here is the caller graph for this function:

struct tm DataStock::GetDateTm ( ) const

Get a tm structure of the date.

It allows specifaclly to access week number

Todo:
to make in Utils but only when tests will be written
Returns
struct tm

Definition at line 151 of file DataStock.cpp.

Referenced by THistPainterStock::SetLabelXAxis(), and ListDataStock_Utils::TransformTimeScale().

Here is the caller graph for this function:

virtual type_value_data DataStock::GetMaximum ( ) const
pure virtual

Get the maximum value.

Implemented in DataCSV, MultiData, and SimpleData.

virtual type_value_data DataStock::GetMinimum ( ) const
pure virtual

Get the minimum value.

Implemented in DataCSV, MultiData, and SimpleData.

virtual std::vector<type_value_data> DataStock::GetValues ( ) const
pure virtual

Return the value(s) in a vector.

Implemented in DataCSV, MultiData, and SimpleData.

Referenced by MultiData::HasChanged(), ListObjectStock< T >::SetObjectStock(), PStockLine::SetObjectStock(), and CollectionObjectStock::SetObjectStock().

Here is the caller graph for this function:

virtual bool DataStock::HasChanged ( const DataStock data_to_check) const
pure 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

Implemented in DataCSV, MultiData, and SimpleData.

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

Normal assignment.

Definition at line 118 of file DataStock.cpp.

References date.

Referenced by SimpleData::operator=(), MultiData::operator=(), and DataCSV::operator=().

Here is the caller graph for this function:

DataStock & DataStock::operator= ( DataStock &&  rhs)

Move assignment.

Definition at line 132 of file DataStock.cpp.

References date.

virtual void DataStock::PrintData ( const unsigned int  verbose = 0) const
pure 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

Implemented in DataCSV, MultiData, and SimpleData.

virtual void DataStock::SetData ( const time_t  d,
const std::vector< type_value_data > &  vec 
)
pure virtual

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

Implemented in DataCSV, MultiData, and SimpleData.

void DataStock::SetDate ( const time_t  d)
inline

Modify the date.

Parameters
dnew_date

Definition at line 130 of file DataStock.h.

References date.

Referenced by SimpleData::ExtractCSVLine(), and helper_operator_read_base().

Here is the caller graph for this function:

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

Set only values, do not modify the date.

Implemented in DataCSV, MultiData, and SimpleData.

Field Documentation

time_t DataStock::date
protected

All data have a date associated.


Unix timestamp is used for all.
Localtime is always used ( epoch: 0 <=> 1 hour in Europe )

Definition at line 97 of file DataStock.h.

Referenced by DataStock(), GetDate(), GetDateString(), operator=(), operator==(), SimpleData::SetData(), MultiData::SetData(), DataCSV::SetData(), and SetDate().


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