ANNA Suite  2020b
Multipurpose development suite for Telco applications
Database.hpp
Go to the documentation of this file.
1 // ANNA - Anna is Not Nothingness Anymore //
2 // //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
4 // //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7 
8 
9 #ifndef anna_dbms_oracle_Database_hpp
10 #define anna_dbms_oracle_Database_hpp
11 
12 #include <anna/dbms/Database.hpp>
14 
15 struct OCIEnv;
16 struct OCIError;
17 
18 namespace anna {
19 
20 namespace dbms {
21 
22 namespace oracle {
23 
30 class Database : public dbms::Database {
31 public:
36  Database(const char* dbmsName);
37 
43  Database(const char* componentName, const char* dbmsName);
44 
48  virtual ~Database();
49 
54  OCIError* getErrorHandler() { return a_error; }
55 
60  operator OCIEnv*() { return a_env; }
61 
67  static const char* getClassName() { return "anna::dbms::oracle::Database"; }
68 
77  static char getDecimalPoint() { return st_decimalPoint; }
78 
79 private:
80  OCIEnv* a_env;
81  OCIError* a_error;
82 
83  static char st_decimalPoint;
84 
85  void do_initialize() noexcept(false);
86 
87  dbms::Connection* allocateConnection(const std::string& name, const char* user, const char* password)
88  noexcept(false);
89 
90  dbms::Statement* allocateStatement(const char* name, const std::string& expression, const bool isCritical)
91  noexcept(false);
92 
93  dbms::InputBind* allocateInputBind(const char* name, Data&)
94  noexcept(false);
95  void deallocate(dbms::InputBind* inputBind) ;
96 
97  dbms::OutputBind* allocateOutputBind(const char* name, Data&)
98  noexcept(false);
99  void deallocate(dbms::OutputBind* outputBind) ;
100 
101  static void initializeDecimalPoint() noexcept(false);
102 };
103 
104 #ifdef ANNA_RDBMS_TRACE
105 #define anna_dbms_oracle_check(a,error) \
106  { \
107  Logger::write (Logger::Debug, (#a), __FILE__, __LINE__); \
108  const sword status = (a); \
109  if (status != OCI_SUCCESS) { \
110  anna::dbms::oracle::ResultCode resultCode (status, (error)); \
111  throw DatabaseException (resultCode, __FILE__, __LINE__); \
112  } \
113  }
114 #else
115 #define anna_dbms_oracle_check(a,error) \
116  { \
117  const sword status = (a); \
118  if (status != OCI_SUCCESS) { \
119  anna::dbms::oracle::ResultCode resultCode (status, (error)); \
120  throw DatabaseException (resultCode, __FILE__, __LINE__); \
121  } \
122  }
123 #endif
124 }
125 }
126 }
127 
128 #endif
Definition: Connection.hpp:38
Definition: Statement.hpp:43
Definition: Database.hpp:37
Definition: Data.hpp:27
Definition: OutputBind.hpp:26
Database(const char *dbmsName)
OCIError * getErrorHandler()
Definition: Database.hpp:54
static const char * getClassName()
Definition: Database.hpp:67
Definition: app.hpp:12
static char getDecimalPoint()
Definition: Database.hpp:77
Definition: Database.hpp:30
Definition: InputBind.hpp:18