libpqxx
|
#include <transactor.hxx>
Public Types | |
using | argument_type = TRANSACTION |
Public Member Functions | |
transactor (const std::string &TName="transactor") | |
void | operator() (TRANSACTION &T) |
Overridable transaction definition; insert your database code here. More... | |
void | on_abort (const char[]) noexcept |
Optional overridable function to be called if transaction is aborted. More... | |
void | on_commit () |
Optional overridable function to be called after successful commit. More... | |
void | on_doubt () noexcept |
Overridable function to be called when "in doubt" about outcome. More... | |
std::string | name () const |
The transactor's name. More... | |
Pass an object of your transactor-based class to connection_base::perform() to execute the transaction code embedded in it.
connection_base::perform() is actually a template, specializing itself to any transactor type you pass to it. This means you will have to pass it a reference of your object's ultimate static type; runtime polymorphism is not allowed. Hence the absence of virtual methods in transactor. The exact methods to be called at runtime must be resolved at compile time.
Your transactor-derived class must define a copy constructor. This will be used to create a "clean" copy of your transactor for every attempt that perform() makes to run it.