ANNA Suite  2020b
Multipurpose development suite for Telco applications
Sentence.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_Sentence_hpp
10 #define anna_dbms_Sentence_hpp
11 
12 #include <anna/core/mt/Mutex.hpp>
13 
14 #include <anna/dbms/ResultCode.hpp>
15 
16 namespace anna {
17 
18 namespace xml {
19 class Node;
20 }
21 
22 namespace dbms {
23 
24 class Database;
25 class Connection;
26 class Statement;
27 
32 class Sentence : public Mutex {
33 public:
38  struct Mode { enum _v { ExceptionWhenNotFound, SilentWhenNotFound }; };
39 
45  virtual dbms::ResultCode execute(dbms::Connection& connection) noexcept(false) {
46  return execute(connection, a_dbStatement);
47  }
48 
54  const std::string& getName() const ;
55 
61  void initialize(dbms::Database& database) noexcept(false);
62 
67  bool fetch() noexcept(false);
68 
74  bool fetch(const ResultCode& resultCode) noexcept(false) {
75  return (resultCode.successful() == true) ? fetch() : false;
76  }
77 
82  virtual std::string asString() const ;
83 
89  virtual xml::Node* asXML(xml::Node* parent) const ;
90 
91 protected:
96  Sentence(const Mode::_v mode = Mode::ExceptionWhenNotFound) :
97  a_mode(mode), a_dbStatement(NULL)
98  {;}
99 
105  dbms::ResultCode execute(dbms::Connection& connection, dbms::Statement* statement) noexcept(false);
106 
111  virtual dbms::Statement* do_initialize(dbms::Database&) noexcept(false) = 0;
112 
113 private:
114  const Mode::_v a_mode;
115  dbms::Statement* a_dbStatement;
116 };
117 
118 }
119 }
120 
121 #endif
122 
Sentence(const Mode::_v mode=Mode::ExceptionWhenNotFound)
Definition: Sentence.hpp:96
Definition: Connection.hpp:38
Definition: Node.hpp:56
Definition: Statement.hpp:43
bool fetch(const ResultCode &resultCode) noexcept(false)
Definition: Sentence.hpp:74
Definition: Database.hpp:37
_v
Definition: Sentence.hpp:38
Definition: Sentence.hpp:32
xml::Node Node
Definition: Node.hpp:21
virtual dbms::ResultCode execute(dbms::Connection &connection) noexcept(false)
Definition: Sentence.hpp:45
Definition: app.hpp:12
Definition: Sentence.hpp:38
Definition: Mutex.hpp:41
Definition: ResultCode.hpp:29