OCILIB (C and C++ Driver for Oracle)  4.7.3
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
Enqueue.hpp
1 /*
2  * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI)
3  *
4  * Website: http://www.ocilib.net
5  *
6  * Copyright (c) 2007-2021 Vincent ROGIER <vince.rogier@ocilib.net>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #pragma once
22 
23 #include "ocilibcpp/types.hpp"
24 
25 // ReSharper disable CppClangTidyMiscMisplacedConst
26 
27 namespace ocilib
28 {
29 
30 inline Enqueue::Enqueue(const TypeInfo &typeInfo, const ostring& queueName)
31 {
32  Acquire(core::Check(OCI_EnqueueCreate(typeInfo, queueName.c_str())), reinterpret_cast<HandleFreeFunc>(OCI_EnqueueFree), nullptr, nullptr);
33 }
34 
35 inline void Enqueue::Put(const Message &message)
36 {
37  core::Check(OCI_EnqueuePut(*this, message));
38 }
39 
41 {
42  return EnqueueVisibility(static_cast<EnqueueVisibility::Type>(core::Check(OCI_EnqueueGetVisibility(*this))));
43 }
44 
46 {
48 }
49 
51 {
52  return EnqueueMode(static_cast<EnqueueMode::Type>(core::Check(OCI_EnqueueGetSequenceDeviation(*this))));
53 }
54 
55 inline void Enqueue::SetMode(EnqueueMode value)
56 {
58 }
59 
61 {
62  unsigned int size = OCI_SIZE_BUFFER;
63 
64  core::ManagedBuffer<unsigned char> buffer(static_cast<size_t>(size + 1));
65 
66  core::Check(OCI_EnqueueGetRelativeMsgID(*this, static_cast<AnyPointer>(buffer), &size));
67 
68  return core::MakeRaw(buffer, size);
69 }
70 
71 inline void Enqueue::SetRelativeMsgID(const Raw &value)
72 {
73  const AnyPointer data = value.empty() ? nullptr : static_cast<AnyPointer>(const_cast<Raw::value_type*>(&value[0])) ;
74 
75  core::Check(OCI_EnqueueSetRelativeMsgID(*this, data, static_cast<unsigned int>(value.size())));
76 }
77 
78 }
OCI_SYM_PUBLIC unsigned int OCI_API OCI_EnqueueGetSequenceDeviation(OCI_Enqueue *enqueue)
Return the sequence deviation of messages to enqueue to the queue.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_EnqueueGetVisibility(OCI_Enqueue *enqueue)
Get the enqueuing/locking behavior.
OCILIB ++ Namespace.
void Put(const Message &message)
Enqueue a message the on queue associated to the Enqueue object.
Definition: Enqueue.hpp:35
Raw MakeRaw(AnyPointer result, unsigned int size)
Internal usage. Constructs a C++ Raw object from the given OCILIB raw buffer.
Definition: Utils.hpp:70
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.
Definition: Utils.hpp:53
OCI_SYM_PUBLIC boolean OCI_API OCI_EnqueueSetRelativeMsgID(OCI_Enqueue *enqueue, const void *id, unsigned int len)
Set a message identifier to use for enqueuing messages using a sequence deviation.
OCI_SYM_PUBLIC boolean OCI_API OCI_EnqueueGetRelativeMsgID(OCI_Enqueue *enqueue, void *id, unsigned int *len)
Get the current associated message identifier used for enqueuing messages using a sequence deviation...
OCI_SYM_PUBLIC OCI_Enqueue *OCI_API OCI_EnqueueCreate(OCI_TypeInfo *typinf, const otext *name)
Create a Enqueue object for the given queue.
void * AnyPointer
Alias for the generic void pointer.
Definition: config.hpp:129
Raw GetRelativeMsgID() const
Get the current associated message identifier used for enqueuing messages using a sequence deviation...
Definition: Enqueue.hpp:60
Template Enumeration template class providing some type safety to some extends for manipulating enume...
Definition: core.hpp:117
void SetMode(EnqueueMode value)
Set the enqueuing mode of messages to put in the queue.
Definition: Enqueue.hpp:55
core::Enum< EnqueueVisibilityValues > EnqueueVisibility
Message visibility after begin queued.
Definition: types.hpp:7794
OCI_SYM_PUBLIC boolean OCI_API OCI_EnqueuePut(OCI_Enqueue *enqueue, OCI_Msg *msg)
Enqueue a message on the queue associated to the Enqueue object.
Internal usage. Provide a buffer class with RAII capabilities.
Definition: core.hpp:196
OCI_SYM_PUBLIC boolean OCI_API OCI_EnqueueSetVisibility(OCI_Enqueue *enqueue, unsigned int visibility)
Set whether the new message is enqueued as part of the current transaction.
Enqueue(const TypeInfo &typeInfo, const ostring &queueName)
Create a Enqueue object for the given queue.
Definition: Enqueue.hpp:30
OCI_SYM_PUBLIC boolean OCI_API OCI_EnqueueFree(OCI_Enqueue *enqueue)
Free a Enqueue object.
OCI_SYM_PUBLIC boolean OCI_API OCI_EnqueueSetSequenceDeviation(OCI_Enqueue *enqueue, unsigned int sequence)
Set the enqueuing sequence of messages to put in the queue.
std::vector< unsigned char > Raw
C++ counterpart of SQL RAW data type.
Definition: config.hpp:138
Provides type information on Oracle Database objects.
Definition: types.hpp:4508
EnqueueVisibility GetVisibility() const
Get the enqueuing/locking behavior.
Definition: Enqueue.hpp:40
void SetVisibility(EnqueueVisibility value)
Set whether the new message is enqueued as part of the current transaction.
Definition: Enqueue.hpp:45
AQ message.
Definition: types.hpp:7399
core::Enum< EnqueueModeValues > EnqueueMode
Message enqueuing mode.
Definition: types.hpp:7772
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 ) ...
Definition: config.hpp:120
EnqueueMode GetMode() const
Return the enqueuing mode of messages to enqueue.
Definition: Enqueue.hpp:50
void SetRelativeMsgID(const Raw &value)
Set a message identifier to use for enqueuing messages using a sequence deviation.
Definition: Enqueue.hpp:71