OCILIB (C and C++ Driver for Oracle)  4.7.5
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
Loading...
Searching...
No Matches
ocilib::Subscription Class Reference

Subscription to database or objects changes. More...

#include <types.hpp>

Inherits ocilib::core::HandleHolder< OCI_Subscription * >.

Public Types

enum  ChangeTypesValues { ObjectChanges = OCI_CNT_OBJECTS , RowChanges = OCI_CNT_ROWS , DatabaseChanges = OCI_CNT_DATABASES , AllChanges = OCI_CNT_ALL }
 Subscription changes flags values. More...
 
typedef void(* NotifyHandlerProc) (Event &evt)
 User callback for subscriptions event notifications.
 
typedef core::Flags< ChangeTypesValuesChangeTypes
 Subscription changes flags.
 

Public Member Functions

 Subscription ()
 Default constructor.
 
void Register (const Connection &connection, const ostring &name, ChangeTypes changeTypes, NotifyHandlerProc handler, unsigned int port=0, unsigned int timeout=0)
 Register a notification against the given database.
 
void Unregister ()
 Unregister a previously registered notification.
 
void Watch (const ostring &sql)
 Add a SQL query to monitor.
 
ostring GetName () const
 Return the name of the given registered subscription.
 
unsigned int GetTimeout () const
 Return the timeout of the given registered subscription.
 
unsigned int GetPort () const
 Return the port used by the notification.
 
Connection GetConnection () const
 Return the connection associated with a subscription handle.
 

Detailed Description

Subscription to database or objects changes.

This class wraps the OCILIB object handle OCI_Subscription and its related methods

Warning
Environment::Events flag must be passed to Environment::Initialize() to be able to use subscriptions

Definition at line 7067 of file types.hpp.

Member Typedef Documentation

◆ NotifyHandlerProc

ocilib::Subscription::NotifyHandlerProc

User callback for subscriptions event notifications.

Definition at line 7080 of file types.hpp.

◆ ChangeTypes

Subscription changes flags.

Possible values are Subscription::ChangeTypesValues

Definition at line 7106 of file types.hpp.

Member Enumeration Documentation

◆ ChangeTypesValues

Subscription changes flags values.

Enumerator
ObjectChanges 

Request for changes at objects (e.g. tables) level (DDL / DML)

RowChanges 

Request for changes at rows level (DML)

DatabaseChanges 

Request for changes at database level (startup, shutdown)

AllChanges 

Request for all changes

Definition at line 7087 of file types.hpp.

Constructor & Destructor Documentation

◆ Subscription()

ocilib::Subscription::Subscription ( )
inline

Default constructor.

Definition at line 31 of file Subscription.hpp.

Member Function Documentation

◆ Register()

void ocilib::Subscription::Register ( const Connection connection,
const ostring name,
ChangeTypes  changeTypes,
NotifyHandlerProc  handler,
unsigned int  port = 0,
unsigned int  timeout = 0 
)
inline

Register a notification against the given database.

Parameters
connection- Connection handle
name- Notification name
changeTypes- Subscription type
handler- User handler callback
port- Port to use for notifications
timeout- notification timeout
Note
Requires Oracle Client 10gR2 or above

Definition at line 45 of file Subscription.hpp.

References ocilib::core::Check(), and OCI_SubscriptionRegister().

◆ Unregister()

void ocilib::Subscription::Unregister ( )
inline

Unregister a previously registered notification.

Note
Environment::Cleanup() will automatically unregister any non unregistered subscriptions
If the database connection passed to Register() has been closed by the time that the application calls Unregister(), the library internally reconnects to the given database, performs the unregistration and then disconnects

Definition at line 64 of file Subscription.hpp.

◆ Watch()

void ocilib::Subscription::Watch ( const ostring sql)
inline

Add a SQL query to monitor.

Definition at line 71 of file Subscription.hpp.

References ocilib::core::Check(), ocilib::Statement::Execute(), GetConnection(), and OCI_SubscriptionAddStatement().

◆ GetName()

ostring ocilib::Subscription::GetName ( ) const
inline

Return the name of the given registered subscription.

Definition at line 80 of file Subscription.hpp.

References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_SubscriptionGetName().

◆ GetTimeout()

unsigned int ocilib::Subscription::GetTimeout ( ) const
inline

Return the timeout of the given registered subscription.

Definition at line 85 of file Subscription.hpp.

References ocilib::core::Check(), and OCI_SubscriptionGetTimeout().

◆ GetPort()

unsigned int ocilib::Subscription::GetPort ( ) const
inline

Return the port used by the notification.

Definition at line 90 of file Subscription.hpp.

References ocilib::core::Check(), and OCI_SubscriptionGetPort().

◆ GetConnection()

Connection ocilib::Subscription::GetConnection ( ) const
inline

Return the connection associated with a subscription handle.

Note
It may return a null connection object if the connection used at Register() time has been closed

Definition at line 95 of file Subscription.hpp.

References ocilib::core::Check(), and OCI_SubscriptionGetConnection().

Referenced by Watch().