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;
187 Connection connection(pConnection,
nullptr);
189 res = handler(connection,
197 inline void Environment::NotifyHandler(
OCI_Event *pEvent)
208 inline void Environment::NotifyHandlerAQ(
OCI_Dequeue *pDequeue)
214 Dequeue dequeue(pDequeue, Environment::GetEnvironmentHandle());
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);
238 inline core::Handle * Environment::GetEnvironmentHandle()
240 return GetInstance()._handle.GetHandle();
243 inline Environment& Environment::GetInstance()
245 Environment* handle =
static_cast<Environment*
>(
OCI_GetUserData(
nullptr));
246 if (handle !=
nullptr)
251 static Environment environment;
258 inline Environment::Environment() : _charMaxSize(0), _initialized(false), _guard(core::
SynchronizationMode::Unsafe)
263 inline void Environment::SelfInitialize(EnvironmentFlags mode,
const ostring& libpath)
273 _callbacks.SetGuard(&_guard);
275 _handle.AcquireTransient
283 _charMaxSize = ComputeCharMaxSize(
GetCharset());
286 inline void Environment::SelfCleanup()
288 _guard.SetMode(core::SynchronizationMode::Unsafe);
290 _callbacks.SetGuard(
nullptr);
299 _initialized =
false;
A connection or session with a specific database.
FailoverResult(* TAFHandlerProc)(Connection &con, FailoverRequest failoverRequest, FailoverEvent failoverEvent)
User callback for TAF event notifications.
core::Enum< FailoverRequestValues > FailoverRequest
Failover requests.
core::Enum< FailoverEventValues > FailoverEvent
Failover events.
void(* NotifyAQHandlerProc)(Dequeue &dequeue)
User callback for dequeue event notifications.
Static class in charge of library initialization / cleanup.
static bool SetFormat(FormatType formatType, const ostring &format)
Set the format string for implicit string conversions of the given type.
static unsigned int GetRuntimeMajorVersion()
Return the major version number of OCI used at runtime.
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.
static unsigned int GetRuntimeRevisionVersion()
Return the revision version number of OCI used at runtime.
void(* HAHandlerProc)(Connection &con, HAEventSource eventSource, HAEventType eventType, Timestamp &time)
User callback for HA event notifications.
static OracleVersion GetCompileVersion()
Return the version of OCI used for compiling OCILIB.
static Environment::EnvironmentFlags GetMode()
Return the Environment mode flags.
static unsigned int GetCompileRevisionVersion()
Return the revision version number of OCI used for compiling OCILIB.
core::Enum< CharsetModeValues > CharsetMode
Environment charset mode.
core::Enum< ImportModeValues > ImportMode
OCI libraries import mode.
static void EnableWarnings(bool value)
Enable or disable Oracle warning notifications.
static big_uint GetAllocatedBytes(AllocatedBytesFlags 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 OracleVersion GetRuntimeVersion()
Return the version of OCI used at runtime.
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.
static void Initialize(EnvironmentFlags mode=Environment::Default, const ostring &libpath=OTEXT(""))
Initialize the OCILIB environment.
static void Cleanup()
Clean up all resources allocated by the environment.
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.
core::Enum< HAEventTypeValues > HAEventType
Type of HA events.
static unsigned int GetCompileMinorVersion()
Return the minor version number of OCI used for compiling OCILIB.
static bool Initialized()
Return true if the environment has been successfully initialized.
static Environment::CharsetMode GetCharset()
Return the OCILIB charset type.
static Environment::ImportMode GetImportMode()
Return the Oracle shared library import mode.
static unsigned int GetRuntimeMinorVersion()
Return the minor version number of OCI used at runtime.
static unsigned int GetCompileMajorVersion()
Return the major version number of OCI used for compiling OCILIB.
static ostring GetFormat(FormatType formatType)
Return the format string for implicit string conversions of the given type.
static unsigned int GetCharMaxSize()
Return maximum size for a character.
core::Enum< HAEventSourceValues > HAEventSource
Source of HA events.
void(* NotifyHandlerProc)(Event &evt)
User callback for subscriptions event notifications.
Object identifying the SQL data type TIMESTAMP.
Template Enumeration template class providing some type safety to some extends for manipulating enume...
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.
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 boolean OCI_API OCI_SetUserData(OCI_Connection *con, void *data)
Associate a pointer to user data to the given connection.
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.
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.
struct OCI_Dequeue OCI_Dequeue
OCILIB encapsulation of A/Q dequeuing operations.
struct OCI_Connection OCI_Connection
Oracle physical connection.
struct OCI_Timestamp OCI_Timestamp
Oracle internal timestamp representation.
struct OCI_Environment OCI_Environment
Environment object.
void(* POCI_HA_HANDLER)(OCI_Connection *con, unsigned int source, unsigned int event, OCI_Timestamp *time)
HA (High Availability) events Notification User callback prototype.
struct OCI_Event OCI_Event
OCILIB encapsulation of Oracle DCN event.
OCI_SYM_PUBLIC boolean OCI_API OCI_Cleanup(void)
Clean up all resources allocated by the library.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetOCICompileVersion(void)
Return the version of OCI used for compilation.
OCI_SYM_PUBLIC boolean OCI_API OCI_SetHAHandler(POCI_HA_HANDLER handler)
Set the High availability (HA) user handler.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetCharset(void)
Return the OCILIB charset type.
OCI_SYM_PUBLIC boolean OCI_API OCI_EnableWarnings(boolean value)
Enable or disable Oracle warning notifications.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetOCIRuntimeVersion(void)
Return the version of OCI used at runtime.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetImportMode(void)
Return the Oracle shared library import mode.
OCI_SYM_PUBLIC boolean OCI_API OCI_Initialize(POCI_ERROR err_handler, const otext *lib_path, unsigned int mode)
Initialize the library.
OCI_SYM_PUBLIC big_uint OCI_API OCI_GetAllocatedBytes(unsigned int mem_type)
Return the current number of bytes allocated internally in the library.
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.
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.
OCI_SYM_PUBLIC const void *OCI_API OCI_HandleGetEnvironment(void)
Return the OCI Environment Handle (OCIEnv *) of OCILIB library.
OCI_SYM_PUBLIC OCI_Subscription *OCI_API OCI_EventGetSubscription(OCI_Event *event)
Return the subscription handle that generated this event.
static T Check(T result)
Internal usage. Checks if the last OCILIB function call has raised an error. If so,...
ostring MakeString(const otext *result, int size=-1)
Internal usage. Constructs a C++ string object from the given OCILIB string pointer.
SynchronizationMode
Internal usage. Synchronization mode enumeration.
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 )
void * CallbackPointer
Alias used for storing user callback method pointers.
void * AnyPointer
Alias for the generic void pointer.
core::Enum< OracleVersionValues > OracleVersion
Oracle Version.