23 #include "ocilibcpp/types.hpp" 34 GetInstance().SelfInitialize(mode, libpath);
39 GetInstance().SelfCleanup();
44 #ifdef OCILIBPP_DEBUG_MEMORY_ENABLED 46 core::GetMemoryDebugInfo().PrintAllocations();
54 return GetInstance()._mode;
69 return GetInstance()._charMaxSize;
79 return GetInstance()._initialized;
141 startMode.GetValues(), startFlags.GetValues(), spfile.c_str() ));
148 shutdownMode.GetValues(), shutdownFlags.GetValues() ));
160 SetUserCallback<HAHandlerProc>(GetEnvironmentHandle(), handler);
163 inline void Environment::HAHandler(
OCI_Connection *pConnection,
unsigned int source,
unsigned int event,
OCI_Timestamp *pTimestamp)
165 const HAHandlerProc handler = GetUserCallback<HAHandlerProc>(GetEnvironmentHandle());
170 Timestamp timestamp(pTimestamp, connection.GetHandle());
174 HAEventType (static_cast<HAEventType::Type> (event)),
179 inline unsigned int Environment::TAFHandler(
OCI_Connection *pConnection,
unsigned int type,
unsigned int event)
181 unsigned int res = OCI_FOC_OK;
189 res = handler(connection,
197 inline void Environment::NotifyHandler(
OCI_Event *pEvent)
208 inline void Environment::NotifyHandlerAQ(
OCI_Dequeue *pDequeue)
220 T Environment::GetUserCallback(
AnyPointer ptr)
222 return reinterpret_cast<T
>(GetInstance()._callbacks.Get(ptr));
226 void Environment::SetUserCallback(
AnyPointer ptr, T callback)
230 GetInstance()._callbacks.Set(ptr, reinterpret_cast<CallbackPointer>(callback));
234 GetInstance()._callbacks.Remove(ptr);
239 void Environment::SetSmartHandle(
AnyPointer ptr, T handle)
243 GetInstance()._handles.Set(ptr, handle);
247 GetInstance()._handles.Remove(ptr);
254 return dynamic_cast<T
>(GetInstance()._handles.Get(ptr));
257 inline core::Handle * Environment::GetEnvironmentHandle()
259 return GetInstance()._handle.GetHandle();
265 if (handle !=
nullptr)
277 inline Environment::Environment() : _charMaxSize(0), _initialized(
false)
292 _callbacks.SetLocker(&_locker);
293 _handles.SetLocker(&_locker);
297 _charMaxSize = ComputeCharMaxSize(
GetCharset());
300 inline void Environment::SelfCleanup()
302 _locker.SetAccessMode(
false);
304 _callbacks.SetLocker(
nullptr);
305 _handles.SetLocker(
nullptr);
314 _initialized =
false;
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetOCIRuntimeVersion(void)
Return the version of OCI used at runtime.
static void Initialize(EnvironmentFlags mode=Environment::Default, const ostring &libpath=OTEXT(""))
Initialize the OCILIB environment.
Internal usage. Interface for handling ownership and relationship of a C API handle.
void(* NotifyAQHandlerProc)(Dequeue &dequeue)
User callback for dequeue event notifications.
static void EnableWarnings(bool value)
Enable or disable Oracle warning notifications.
static unsigned int GetCompileRevisionVersion()
Return the revision version number of OCI used for compiling OCILIB.
struct OCI_Connection OCI_Connection
Oracle physical connection.
OCI_SYM_PUBLIC boolean OCI_API OCI_SetUserPassword(const otext *db, const otext *user, const otext *pwd, const otext *new_pwd)
Change the password of the given user on the given database.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetImportMode(void)
Return the Oracle shared library import mode.
void(* HAHandlerProc)(Connection &con, HAEventSource eventSource, HAEventType eventType, Timestamp &time)
User callback for HA event notifications.
OCI_SYM_PUBLIC boolean OCI_API OCI_Initialize(POCI_ERROR err_handler, const otext *lib_path, unsigned int mode)
Initialize the library.
static ostring GetFormat(FormatType formatType)
Return the format string for implicit string conversions of the given type.
static void ShutdownDatabase(const ostring &db, const ostring &user, const ostring &pwd, Environment::ShutdownFlags shutdownFlags, Environment::ShutdownMode shutdownMode, Environment::SessionFlags sessionFlags=SessionSysDba)
Shutdown a database instance.
A connection or session with a specific database.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetCharset(void)
Return the OCILIB charset type.
static unsigned int GetCompileMinorVersion()
Return the minor version number of OCI used for compiling OCILIB.
struct OCI_Dequeue OCI_Dequeue
OCILIB encapsulation of A/Q dequeuing operations.
static T Check(T result)
Internal usage. Checks if the last OCILIB function call has raised an error. If so, it raises a C++ exception using the retrieved error handle.
static unsigned int GetCompileMajorVersion()
Return the major version number of OCI used for compiling OCILIB.
static Environment::EnvironmentFlags GetMode()
Return the Environment mode flags.
OCI_SYM_PUBLIC OCI_Subscription *OCI_API OCI_EventGetSubscription(OCI_Event *event)
Return the subscription handle that generated this event.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetOCICompileVersion(void)
Return the version of OCI used for compilation.
static Environment::ImportMode GetImportMode()
Return the Oracle shared library import mode.
struct OCI_Timestamp OCI_Timestamp
Oracle internal timestamp representation.
static void ChangeUserPassword(const ostring &db, const ostring &user, const ostring &pwd, const ostring &newPwd)
Change the password of the given user on the given database.
OCI_SYM_PUBLIC void *OCI_API OCI_GetUserData(OCI_Connection *con)
Return the pointer to user data previously associated with the connection.
OCI_SYM_PUBLIC const void *OCI_API OCI_HandleGetEnvironment(void)
Return the OCI Environment Handle (OCIEnv *) of OCILIB library.
ostring MakeString(const otext *result, int size=-1)
Internal usage. Constructs a C++ string object from the given OCILIB string pointer.
Static class in charge of library initialization / cleanup.
void(* NotifyHandlerProc)(Event &evt)
User callback for subscriptions event notifications.
void * AnyPointer
Alias for the generic void pointer.
static void Cleanup()
Clean up all resources allocated by the environment.
Template Enumeration template class providing some type safety to some extends for manipulating enume...
OCI_SYM_PUBLIC boolean OCI_API OCI_SetHAHandler(POCI_HA_HANDLER handler)
Set the High availability (HA) user handler.
core::Enum< OracleVersionValues > OracleVersion
Oracle Version.
static bool Initialized()
Return true if the environment has been successfully initialized.
OCI_SYM_PUBLIC boolean OCI_API OCI_DatabaseStartup(const otext *db, const otext *user, const otext *pwd, unsigned int sess_mode, unsigned int start_mode, unsigned int start_flag, const otext *spfile)
Start a database instance.
static OracleVersion GetRuntimeVersion()
Return the version of OCI used at runtime.
OCI_SYM_PUBLIC boolean OCI_API OCI_Cleanup(void)
Clean up all resources allocated by the library.
static OracleVersion GetCompileVersion()
Return the version of OCI used for compiling OCILIB.
OCI_SYM_PUBLIC boolean OCI_API OCI_SetFormat(OCI_Connection *con, unsigned int type, const otext *format)
Set the format string for implicit string conversions of the given type.
static unsigned int GetRuntimeRevisionVersion()
Return the revision version number of OCI used at runtime.
OCI_SYM_PUBLIC big_uint OCI_API OCI_GetAllocatedBytes(unsigned int mem_type)
Return the current number of bytes allocated internally in the library.
static void SetHAHandler(HAHandlerProc handler)
Set the High availability (HA) user handler.
static unsigned int GetCharMaxSize()
Return maximum size for a character.
OCI_SYM_PUBLIC boolean OCI_API OCI_SetUserData(OCI_Connection *con, void *data)
Associate a pointer to user data to the given connection.
static void StartDatabase(const ostring &db, const ostring &user, const ostring &pwd, Environment::StartFlags startFlags, Environment::StartMode startMode, Environment::SessionFlags sessionFlags=SessionSysDba, const ostring &spfile=OTEXT(""))
Start a database instance.
core::Enum< ImportModeValues > ImportMode
OCI libraries import mode.
OCI_SYM_PUBLIC boolean OCI_API OCI_DatabaseShutdown(const otext *db, const otext *user, const otext *pwd, unsigned int sess_mode, unsigned int shut_mode, unsigned int shut_flag)
Shutdown a database instance.
static big_uint GetAllocatedBytes(AllocatedBytesFlags type)
Return the current number of bytes allocated internally in the library.
core::Enum< HAEventSourceValues > HAEventSource
Source of HA events.
static Environment::CharsetMode GetCharset()
Return the OCILIB charset type.
core::Enum< CharsetModeValues > CharsetMode
Environment charset mode.
static unsigned int GetRuntimeMinorVersion()
Return the minor version number of OCI used at runtime.
std::basic_string< otext, std::char_traits< otext >, std::allocator< otext > > ostring
string class wrapping the OCILIB otext * type and OTEXT() macros ( see Character sets ) ...
static unsigned int GetRuntimeMajorVersion()
Return the major version number of OCI used at runtime.
OCI_SYM_PUBLIC const otext *OCI_API OCI_GetFormat(OCI_Connection *con, unsigned int type)
Return the format string for implicit string conversions of the given type.
static bool SetFormat(FormatType formatType, const ostring &format)
Set the format string for implicit string conversions of the given type.
Object identifying the SQL data type TIMESTAMP.
Dequeue object for dequeuing messages into an Oracle Queue.
struct OCI_Event OCI_Event
OCILIB encapsulation of Oracle DCN event.
OCI_SYM_PUBLIC boolean OCI_API OCI_EnableWarnings(boolean value)
Enable or disable Oracle warning notifications.
FailoverResult(* TAFHandlerProc)(Connection &con, FailoverRequest failoverRequest, FailoverEvent failoverEvent)
User callback for TAF event notifications.