Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies
TSADBRecord.h
1 
2 /* ===================================================================
3 *
4 * T R A D I N G S Y S T E M A P I ™
5 * Copyright © 1999 - 2014 by Peter Ritter ( TradingSystemAPI.com )
6 * A L L R I G H T S R E S E R V E D
7 *
8 * Consult your license regarding permissions and restrictions.
9 * You may obtain a copy of the License at:
10 * http://www.TradingSystemAPI.com/licenses/LICENSE-TSAPI-3.0.html
11 *
12 * ====================================================================
13 */
14 
15 #ifndef TSA_DBRECORD__INCLUDED
16 #define TSA_DBRECORD__INCLUDED
17 
18 #include <vector>
19 
20 #include "TSATime.h"
21 
22 namespace tsa {
23 
24  class appendable;
25  namespace fast{
26  class db_record;
27  }
28 
32  dll_export enum append_flag_type
33  {
37 
41  };
42 
43  /*
44  ** ===================================================
45  ** > > > class table < < <
46  ** ===================================================
47  */
48 
52  class dll_export record {
53  tsa_declare_testable;
54  friend class table;
55  friend class mem_table;
56  appendable* m_appendable_ptr = nullptr;
57  public:
58  date_time timestamp;
59  public:
60  std::vector<variant> fields;
61  public:
62 
67  record(const record& record);
68 
69  // internal
70  record(appendable*);
71 
78  record(size_t num_fields);
79 
84  void operator= (fast::db_record* record);
85 
89  ~record(void);
90 
96  size_t size(void) const;
97 
104  const variant& operator[](size_t position) const;
105 
112  variant& operator[](size_t position);
113 
117  void clear(void);
118 
119  // internal
120  bool is_init(void);
121 
126  void print(std::ostream& stream);
127  public:
128  friend class appendable;
129  };
130 
131  /*
132  ** ===================================================
133  ** > > > class appendable < < <
134  ** ===================================================
135  */
136 
140  class dll_export appendable {
141  tsa_declare_testable;
142  std::vector<record*> m_records;
143  public:
144  appendable(void);
145  ~appendable(void);
146  void deinitialize_records(void);
147  void register_record(class record*);
148  void deregister_record(class record*);
149  virtual class record record(void) = 0;
150  virtual void append(const class record& rec, append_flag_type flag = error_on_duplicate_timestamp) = 0;
151  virtual size_t column_count(void) const = 0;
152  };
153 
154 } // namespace tsa
155 
156 #endif
Set this flag to force the system to automatically fix duplicate timstamps, by setting the new record...
Definition: TSADBRecord.h:40
append_flag_type
Values that represent append flag types.
Definition: TSADBRecord.h:32
Throw an exception when a duplicate timestamp is encountered. This is normally the default behaviour...
Definition: TSADBRecord.h:36
Namespace for the &#39;Trading System API&#39; library.
Definition: original1.TSA3Core.cpp:20
Supports &#39;write&#39;, &#39;update&#39;, &#39;delete&#39;, and &#39;read&#39; operations on series_base tables.
variant objects can represent values of different types.
Definition: TSAVariant.h:140
Class representing a database record.
Definition: TSADBRecord.h:52
Class representing a gregorian-date and time-of-day combination. The time component has microsecond r...
Definition: TSATime.h:428
Represents an object to which a record object can be appended.
Definition: TSADBRecord.h:140
Class mem_table represents a memory based table. mem_table objects can be used in strategies both for...
Definition: TSAMemTable.h:48