fintp_udal
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DataColumn.h
Go to the documentation of this file.
1 /*
2 * FinTP - Financial Transactions Processing Application
3 * Copyright (C) 2013 Business Information Systems (Allevo) S.R.L.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>
17 * or contact Allevo at : 031281 Bucuresti, 23C Calea Vitan, Romania,
18 * phone +40212554577, office@allevo.ro <mailto:office@allevo.ro>, www.allevo.ro.
19 */
20 
21 #ifndef DATACOLUMN_H
22 #define DATACOLUMN_H
23 
24 #include "Collections.h"
25 #include "DataParameter.h"
26 
27 namespace FinTP
28 {
29  class DataCommand;
30 
35  {
36  protected :
37 
38  string m_Name;
40  unsigned int m_Dimension;
41  int m_Scale;
42 
47 
48  public:
49 
50  //.ctor
51  DataColumnBase() : m_Name( "" ), m_Type( DataType::INVALID_TYPE ), m_BaseType( DataType::INVALID_TYPE ), m_Dimension( 0 ),
52  m_Scale( 0 ), m_StoragePointer( NULL ), m_BufferIndicator( 0 ) {};
53 
54  DataColumnBase( unsigned int dimension, int scale, const string& name = "", const DataType::DATA_TYPE dataType = DataType::INVALID_TYPE, const DataType::DATA_TYPE baseType = DataType::INVALID_TYPE ) :
55  m_Name( name ), m_Type( dataType ), m_BaseType( baseType ), m_Dimension( dimension ), m_Scale( scale ),
56  m_StoragePointer( NULL ), m_BufferIndicator( 0 ) {};
57 
58  DataColumnBase( const DataColumnBase& source ) : m_Name( source.m_Name ), m_Type( source.m_Type ), m_BaseType( source.m_BaseType ),
59  m_Dimension( source.m_Dimension ), m_Scale( source.m_Scale ), m_StoragePointer( source.m_StoragePointer ), m_BufferIndicator( source.m_BufferIndicator ) {}
60  DataColumnBase& operator=( const DataColumnBase& source )
61  {
62  if ( this == &source )
63  return *this;
64 
65  m_Name = source.m_Name;
66  m_Type = source.m_Type;
67  m_BaseType = source.m_BaseType;
68  m_Dimension = source.m_Dimension;
69  m_Scale = source.m_Scale;
70  m_StoragePointer = source.m_StoragePointer;
71  m_BufferIndicator = source.m_BufferIndicator;
72 
73  return *this;
74  }
75 
76  virtual ~DataColumnBase()
77  {
78  if ( m_StoragePointer != NULL )
79  m_StoragePointer = NULL;
80  };
81 
82  void setType( const DataType::DATA_TYPE dataType ) {
83  m_Type = dataType;
84  }
85 
91  return m_Type;
92  }
93 
94  void setBaseType( const DataType::DATA_TYPE dataType ) {
95  m_BaseType = dataType;
96  }
98  return m_BaseType;
99  }
100 
101  virtual void setDimension( const unsigned int newValue ) {
102  m_Dimension = newValue;
103  }
104  unsigned int getDimension() const {
105  return m_Dimension;
106  }
107 
108  void setName( const string& newName ) {
109  m_Name = newName;
110  }
111  string getName() const {
112  return m_Name;
113  }
114 
115  void setScale( const int newValue ) {
116  m_Scale = newValue;
117  }
118  int getScale() const {
119  return m_Scale;
120  }
121 
123  return m_StoragePointer;
124  }
125 
126  virtual DataColumnBase* Clone() {
127  return NULL;
128  }
129  virtual void Clear() {};
130 
131  const long* getBufferIndicator() {
132  return &m_BufferIndicator;
133  }
134 
135  virtual string getString();
136  virtual int getInt();
137  virtual short getShort();
138  virtual long getLong();
139 
140  virtual string Dump() {
141  return "base";
142  }
143 
144  virtual void Sync() {};
145  };
146 
156  template < class T >
164  {
165  public :
166 
167  // could translate to DataColumn< string >( 100, 10 );
168  explicit DataColumn( unsigned int dimension = 0, int scale = 0, const string& name = "" );
169 
170  virtual ~DataColumn( );
171 
172  virtual void setValue( T value );
173  virtual T getValue();
174 
175  virtual DataColumnBase* Clone();
176  void Clear();
177 
178  static DataType::DATA_TYPE getColType();
179 
180  virtual void setDimension( const unsigned int newValue )
181  {
182  DataColumnBase::setDimension( newValue );
183  }
184 
185  // oracle column will overrride this function to convert numeric format to int
186  virtual long getLong() {
187  return DataColumnBase::getLong();
188  }
189  virtual int getInt() {
190  return DataColumnBase::getInt();
191  }
192  virtual short getShort() {
193  return DataColumnBase::getShort();
194  }
195 
196  virtual string Dump() {
197  return "derived";
198  }
199  virtual void Sync();
200 
201  protected :
202 
204 
205  private :
206 
207  DataColumn( const DataColumn< T >& source );
208  DataColumn< T >& operator=( const DataColumn< T >& source );
209  };
210 
211  template <>
213  {
214  return DataType::CHAR_TYPE;
215  //VARCHAR_TYPE
216  }
217 
218  template <>
220  {
222  }
223 
224  template <>
226  {
227  return DataType::LONGINT_TYPE;
228  }
229 }
230 
231 #endif // DATACOLUMN_H