Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies
TSADataDef.h
1 /* ===================================================================
2 *
3 * T R A D I N G S Y S T E M A P I ™
4 * Copyright © 1999 - 2014 by Peter Ritter ( TradingSystemAPI.com )
5 * A L L R I G H T S R E S E R V E D
6 *
7 * Consult your license regarding permissions and restrictions.
8 * You may obtain a copy of the License at:
9 * http://www.TradingSystemAPI.com/licenses/LICENSE-TSAPI-3.0.html
10 *
11 * ====================================================================
12 */
13 
14 #ifndef TSA_DATA_DEF__INCLUDED
15 #define TSA_DATA_DEF__INCLUDED
16 
17 #include "TSATypeDef.h"
18 #include "TSARecord.h"
19 //#include "TSASerialize.h"
20 
21 namespace tsa {
22 
25  namespace fast{
26  class database;
27  }
28 
29  /*
30  ** ================================================================
31  ** >>> class data_def <<<
32  ** ================================================================
33  */
34 
88  class column_defs : public object{//, public serialize::I{
89  tsa_declare_testable;
90  friend class fast::db_record;
91  private:
92  std::vector<fast::db_record::field_info> m_field_infos;
93  public:
95  column_defs(void);
96 
99 
101  column_defs(const std::string& column_definition_string);
102 
104  column_defs(const char* column_definition_string);
105 
106  // Internal - Initializes @b self with the schema structure previously saved under @b data_def_name in @b series_base.
107  column_defs(fast::database& series_base, const std::string& data_def_name);
108 
110  column_defs(const column_defs&);
111 
113  void operator=(const column_defs& other);
114 
116  bool defined(void)const;
117 
124  void from_string(const std::string& column_definition_string);
125 
127  std::string to_string(void)const;
128 
130  bool is_equal(const column_defs& other);
131 
133  void clear();
134 
136  void remove_column(const std::string& column_name);
137 
145  void add_column(type_t column_type, const std::string& column_name, size_t length = 1);
146  public:
147 
149  size_t column_count(void)const;
150 
152  size_t size(void)const;
153 
155  size_t column_number(const std::string column_name)const;
156 
158  bool column_exists(const std::string column_name)const;
159 
161  type_t column_type(size_t position)const;
162 
164  const std::string& column_name(size_t position)const;
165 
172  size_t column_field_length(size_t position)const;
173 
179  type_t column_type(const std::string& field_name)const;
180 
188  size_t column_field_length(const std::string& column_name)const;
189 
196  bool has_pointer_field(void)const;
197  std::vector<std::string> column_names(bool include_timestamp_field = false)const;
198  public:
199  void print(std::ostream& _stream)const;
200  virtual std::ostream& write(std::ostream&)const;
201  virtual std::istream& read(std::istream&);
202 
203  void Write(out_storage_stream&)const;//still need this for reading from BLOB
204  void Read(in_storage_stream&);
205  void random_columns(size_t max_num_fields, size_t max_string_len, bool unsigned_fields_ok = true);
206  public:
207  template<class Archive>
208  void save(Archive & ar) const
209  {
210  ar(m_field_infos);
211  }
212 
213  template<class Archive>
214  void load(Archive & ar)
215  {
216  ar(m_field_infos);
217  }
218  };
219 
226  std::ostream& operator<<(std::ostream& stream, const column_defs& _col_def);
227 
229 }
230 
231 #endif
Namespace for the &#39;Trading System API&#39; library.
Definition: original1.TSA3Core.cpp:20
Class for managing native timeseries database files. Extremely high speed data access.
Definition: TSADatabase.h:118
Defines the columnar structure of a table. Each column has a name, data type and field size...
Definition: TSADataDef.h:88
std::ostream & operator<<(std::ostream &s, const transaction &t)
Writes human readable transaction information to stream.
Definition: TSAOrder.cpp:779
_value_types_type
Data type enumeration used throughout the library. Intended to be used via type_t.
Definition: TSATypeDef.h:166
Parent class for many library classes.
Definition: TSATypeDef.h:462