OCILIB (C and C++ Driver for Oracle)  4.7.6
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-2023 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  Connection connection = typeInfo.GetConnection();
33 
34  AcquireAllocated
35  (
36  core::Check(OCI_EnqueueCreate(typeInfo, queueName.c_str())),
37  connection.GetHandle()
38  );
39 }
40 
41 inline void Enqueue::Put(const Message &message)
42 {
43  core::Check(OCI_EnqueuePut(*this, message));
44 }
45 
47 {
48  return EnqueueVisibility(static_cast<EnqueueVisibility::Type>(core::Check(OCI_EnqueueGetVisibility(*this))));
49 }
50 
52 {
54 }
55 
57 {
58  return EnqueueMode(static_cast<EnqueueMode::Type>(core::Check(OCI_EnqueueGetSequenceDeviation(*this))));
59 }
60 
61 inline void Enqueue::SetMode(EnqueueMode value)
62 {
64 }
65 
67 {
68  unsigned int size = OCI_SIZE_BUFFER;
69 
70  core::ManagedBuffer<unsigned char> buffer(static_cast<size_t>(size + 1));
71 
72  core::Check(OCI_EnqueueGetRelativeMsgID(*this, static_cast<AnyPointer>(buffer), &size));
73 
74  return core::MakeRaw(buffer, size);
75 }
76 
77 inline void Enqueue::SetRelativeMsgID(const Raw &value)
78 {
79  const AnyPointer data = value.empty() ? nullptr : static_cast<AnyPointer>(const_cast<Raw::value_type*>(&value[0])) ;
80 
81  core::Check(OCI_EnqueueSetRelativeMsgID(*this, data, static_cast<unsigned int>(value.size())));
82 }
83 
84 }
A connection or session with a specific database.
Definition: types.hpp:1580
void SetVisibility(EnqueueVisibility value)
Set whether the new message is enqueued as part of the current transaction.
Definition: Enqueue.hpp:51
core::Enum< EnqueueModeValues > EnqueueMode
Message enqueuing mode.
Definition: types.hpp:7794
EnqueueVisibility GetVisibility() const
Get the enqueuing/locking behavior.
Definition: Enqueue.hpp:46
EnqueueMode GetMode() const
Return the enqueuing mode of messages to enqueue.
Definition: Enqueue.hpp:56
void SetMode(EnqueueMode value)
Set the enqueuing mode of messages to put in the queue.
Definition: Enqueue.hpp:61
Raw GetRelativeMsgID() const
Get the current associated message identifier used for enqueuing messages using a sequence deviation.
Definition: Enqueue.hpp:66
void SetRelativeMsgID(const Raw &value)
Set a message identifier to use for enqueuing messages using a sequence deviation.
Definition: Enqueue.hpp:77
core::Enum< EnqueueVisibilityValues > EnqueueVisibility
Message visibility after begin queued.
Definition: types.hpp:7816
Enqueue(const TypeInfo &typeInfo, const ostring &queueName)
Create a Enqueue object for the given queue.
Definition: Enqueue.hpp:30
void Put(const Message &message)
Enqueue a message the on queue associated to the Enqueue object.
Definition: Enqueue.hpp:41
AQ message.
Definition: types.hpp:7422
Provides type information on Oracle Database objects.
Definition: types.hpp:4531
Connection GetConnection() const
Return the connection associated with a statement.
Definition: TypeInfo.hpp:52
Template Enumeration template class providing some type safety to some extends for manipulating enume...
Definition: core.hpp:118
Internal usage. Provide a buffer class with RAII capabilities.
Definition: core.hpp:197
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 boolean OCI_API OCI_EnqueuePut(OCI_Enqueue *enqueue, OCI_Msg *msg)
Enqueue a message on the queue associated to the Enqueue object.
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 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 unsigned int OCI_API OCI_EnqueueGetVisibility(OCI_Enqueue *enqueue)
Get the enqueuing/locking behavior.
OCI_SYM_PUBLIC OCI_Enqueue *OCI_API OCI_EnqueueCreate(OCI_TypeInfo *typinf, const otext *name)
Create a Enqueue object for the given queue.
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.
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.
static T Check(T result)
Internal usage. Checks if the last OCILIB function call has raised an error. If so,...
Definition: Utils.hpp:53
Raw MakeRaw(AnyPointer result, unsigned int size)
Internal usage. Constructs a C++ Raw object from the given OCILIB raw buffer.
Definition: Utils.hpp:70
OCILIB ++ Namespace.
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
std::vector< unsigned char > Raw
C++ counterpart of SQL RAW data type.
Definition: config.hpp:138
void * AnyPointer
Alias for the generic void pointer.
Definition: config.hpp:129