15 #ifndef LISTDATASTOCK_H_
16 #define LISTDATASTOCK_H_
20 #include <initializer_list>
24 #include "../utils/TimeScale.h"
25 #include "../utils/FullName.h"
26 #include "../utils/Indicator.h"
27 #include "../utils/Utils.h"
31 #include <boost/any.hpp>
32 #include <boost/variant.hpp>
93 virtual void SetDates(
const time_t first,
const time_t last ) {
108 virtual unsigned int GetSize()
const =0;
111 virtual unsigned int Capacity()
const =0;
116 virtual void Reserve(
const unsigned int new_size) =0;
123 virtual void Clear() =0;
125 virtual void Swap() =0;
142 virtual std::string
policy()
const =0;
256 typedef boost::variant<float**, double**, int**>
var_types;
257 typedef boost::variant<float***, double***, int***>
var_types2;
339 virtual unsigned int GetCArray(
var_types2 arraydata_c,
const EPChrono b_order, std::initializer_list<unsigned int> list_no )
const =0;
379 const unsigned size_indic,
var_types arraydata_c,
const unsigned int offset_begin,
392 virtual void PrintData (
const unsigned int verbose = 0)
const =0;
438 :
public boost::static_visitor<type_value_data>
445 template <
typename T>
455 :
public boost::static_visitor<>
462 template <
typename T>
466 *array =
new T[
size];
469 template <
typename T>
473 *array =
new T*[
size];
479 :
public boost::static_visitor<>
486 template <
typename T>
590 ListData.push_back( static_cast<T &>(data) ); }
603 void PrintData (
const unsigned int verbose = 0)
const;
611 const unsigned int nb_data,
612 const unsigned size_indic,
614 const unsigned int offset_begin,
615 const unsigned int offset_end = 0,
617 bool full_array =
false );
651 std::reverse( res.begin(), res.end() );
666 namespace ListDataStock_Utils {
695 template <
class>
class Policy1,
696 template <
class>
class Policy2,
697 template <
class>
class Policy3,
698 template <
class>
class Policy4
724 template <
class>
class Policy1,
725 template <
class>
class Policy2,
726 template <
class>
class Policy3,
727 template <
class>
class Policy4
740 #endif // LISTDATASTOCK_H_
void operator()(T **array) const
visitor_get_array_set_value()
virtual DataStock & operator[](const unsigned int offset)=0
Access nth element, do not check for the policy chronology.
std::string fullname
fullname seems necessary (convenient) for GUI, never set by constructors
virtual void AddData(DataStock &)=0
Add a copy of the DataStock into the ListDataStock.
virtual void SetDates()=0
Set the correct first/last dates from the DataStock in the vector.
EPChrono bpolicy() const
Return policy as an enumeration type EPChrono, CHRONO / NO_CHRONO.
void Replace(const ListDataStockBase *ldata_in)
Replace all DataStock's of the list with ldata_in.data, without checking for update.
ListDataStock(std::string iname, ETime itmscl, Utils::firstlast_dates idates=Utils::get_fldate_default())
void SetName(const std::string iname)
virtual std::string policy() const =0
Return a string of the chronology policy.
void AddData(DataStock &data)
Add a copy of the DataStock into the ListDataStock.
ListDataStock(std::string iname, ETime itmscl, unsigned int size)
Reserve size for the vector, default DataStock constructor is called (dates and values are set to zer...
void PrintData(const unsigned int verbose=0) const
Nice formatting output on console.
virtual int PutCArray(const ListDataStockBase &ldata_date, const unsigned int nb_data, const unsigned size_indic, var_types arraydata_c, const unsigned int offset_begin, const unsigned int offset_end=0, const EPChrono b_chrono=EPChrono::CHRONO, bool full_array=false)=0
Fill a ListDataStock<T> from a 2 dimensional C-array.
virtual ~ListDataStockBase()
Destructor.
T & operator[](const unsigned int offset)
Access nth element, do not check for the policy chronology.
unsigned int GetSize() const
Return the size of the vector.
virtual time_t LastUpdate() const =0
Get the date of the last data (always chronological meaning)
virtual void PrintData(const unsigned int verbose=0) const =0
Nice formatting output on console.
virtual int AddToList(const ListDataStockBase *)=0
Append all data from a new list ( coming from an Update or ReadCSV normally ) to an existing list...
double type_value_data
Type of the floating values to be stored, can be set to float or double before compilation.
boost::variant< float **, double **, int ** > var_types
time_t GetFirstDate() const
Get first date from the private data member dates.
Implementation of the functions.
void GetVectorData(std::vector< T > &res, const EPChrono chrono) const
const T & NoChronologicAt(const unsigned int offset) const
Get nth element in a non chronological order.
Use a policy PolicyChronologic, default VecNoChronologic.
virtual unsigned int Capacity() const =0
Return the capacity of the vector.
EPChrono
Define convenient name for the chronology, makes algorithms clearer.
virtual void GetVectorData(std::vector< DataCSV > &, const EPChrono) const
time_t GetLastDate() const
Get last date from the private data member dates.
ListDataStockBase(std::string iname, ETime itmscl, Utils::firstlast_dates idates=Utils::get_fldate_default())
Constructor sets name, timescale and optionaly dates.
Define typedef with a default chronology policy for the most common types of ListDataStock.
Classes for data to be stored in ListDataStock.
virtual time_t GetFirstTime() const =0
Get the date of the first data (always chronological meaning)
type_value_data operator()(T **val) const
unsigned int Capacity() const
Return the capacity of the vector.
virtual void Swap()=0
Reduce the capacity of the internal vector to fit its size.
void Reserve(const unsigned int new_size)
Reserve new_size elements.
virtual void Order(const EPChrono chrono)=0
Function to reverse the internal vector in its original policy.
virtual void SetDates(const Utils::firstlast_dates &new_date)
Set dates with a structure Utils::firstlast_dates.
virtual void Replace(const ListDataStockBase *)=0
Replace all DataStock's of the list with ldata_in.data, without checking for update.
boost::variant< float ***, double ***, int *** > var_types2
ListDataStockBase()
Default constructor, set empty names, timescale ETime::not_a_time, dates are zero.
ETime
Enumeration for the different time representation, from instantaneous (INST) to year(YEAR) ...
std::string policy() const
Return a string of the chronology policy.
void Order(const EPChrono b_chronologic=EPChrono::CHRONO)
Function to reverse the internal vector in its original policy.
void operator()(T **array) const
visitor_get_array_allocate(int new_size)
virtual Utils::firstlast_dates GetDates() const
Return the structure Utils::firstlast_dates of the private data member, not from the data...
virtual const DataStock & ChronologicAt(const unsigned int offset) const =0
Get the nth element in a chronological order.
virtual void SetTimeScale(const ETime new_tmscl)
ETime tmscl
TimeScale of the List.
void Swap()
Reduce the capacity of the internal vector to fit its size.
void SetDates()
Set the correct first/last dates from the DataStock in the vector.
ListDataStock & operator=(const ListDataStockBase &rhs)=delete
Deleted assignment operator.
virtual void Reserve(const unsigned int new_size)=0
Reserve new_size elements.
time_t GetFirstTime() const
Get the date of the first data (always chronological meaning)
virtual unsigned int GetSize() const =0
Return the size of the vector.
virtual void SetDates(const time_t first, const time_t last)
Set dates, 2 arguments.
void Clear()
Clear the vector and reinitialize data members to default values.
std::string GetName() const
std::string name
name stores the indicator label with the parameters, it corresponds to its ShortName ...
ListDataStock(std::string iname, ETime itmscl, const std::vector< T > &vec_data)
Constructor accepting a std::vector<DataStock>
virtual std::string GetFullName() const
ListDataStockBase & operator=(const ListDataStockBase &rhs)
Delete assignment operator.
Abstract base class for the ListDataStock, for storing base pointers in vectors.
visitor_get_array_allocate()
void SetDates(time_t first, time_t last)
Set dates, 2 arguments.
virtual void SetFullName(std::string fname)
virtual const DataStock & NoChronologicAt(const unsigned int offset) const =0
Get nth element in a non chronological order.
~ListDataStock()
Destructor.
static SUPPRESS_NOT_USED_WARN firstlast_dates get_fldate_default()
need to be static for using default argument in a function
virtual EPChrono bpolicy() const =0
Return policy as an enumeration type EPChrono, CHRONO / NO_CHRONO.
Utils::firstlast_dates dates
Store the first and last dates of the list Redondant with dates from DataStock, added first for readi...
visitor_get_array_set_value(unsigned int nbi, double valuei)
virtual ETime GetTimeScale() const
std::vector< T > ListData
internal vector of objects DataStock
general structure for dates in csv files
int AddToList(const ListDataStockBase *new_list)
Append all data from a new list ( coming from an Update or ReadCSV normally ) to an existing list...
virtual void GetVectorData(std::vector< MultiData > &, const EPChrono) const
visitor_type_array(int i1, int j1)
time_t LastUpdate() const
Get the date of the last data (always chronological meaning)
virtual unsigned int GetCArray(var_types arraydata_c, const EPChrono b_order, const unsigned int no=0) const =0
Extract the data into a one dimensional C-array.
unsigned int GetCArray(var_types arraydata_c, const EPChrono b_order, const unsigned int no=0) const
Extract the data into a one dimensional C-array.
Abstract base class for all Data to be stored in ListDataStock.
virtual void Clear()=0
Clear the vector and reinitialize data members to default values.
const T & ChronologicAt(const unsigned int offset) const
Get the nth element in a chronological order.
int PutCArray(const ListDataStockBase &ldata_date, const unsigned int nb_data, const unsigned size_indic, var_types arraydata_c, const unsigned int offset_begin, const unsigned int offset_end=0, const EPChrono b_chrono=EPChrono::CHRONO, bool full_array=false)
Fill a ListDataStock<T> from a 2 dimensional C-array.
virtual void GetVectorData(std::vector< SimpleData > &, const EPChrono) const
int TransformTimeScale(const ETime new_tmscl, const ListDataStock< DataCSV, Policy1 > &list_csv_in, const ListDataStock< SimpleData, Policy2 > &list_vol_in, ListDataStock< DataCSV, Policy3 > &list_csv_out, ListDataStock< SimpleData, Policy4 > &list_vol_out)
Transform StockCSV and Volume from M5 into a StockCSV with larger TimeScale, typical DAY to WEEK...