BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlar_accessorvtableutil.h
Go to the documentation of this file.
1/// @file bdlar_accessorvtableutil.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlar_accessorvtableutil.h -*-C++-*-
8#ifndef INCLUDED_BDLAR_ACCESSORVTABLEUTIL
9#define INCLUDED_BDLAR_ACCESSORVTABLEUTIL
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlar_accessorvtableutil bdlar_accessorvtableutil
15/// @brief Provide ...
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlar
19/// @{
20/// @addtogroup bdlar_accessorvtableutil
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlar_accessorvtableutil-purpose"> Purpose</a>
25/// * <a href="#bdlar_accessorvtableutil-classes"> Classes </a>
26/// * <a href="#bdlar_accessorvtableutil-description"> Description </a>
27///
28/// # Purpose {#bdlar_accessorvtableutil-purpose}
29/// Provide ...
30///
31/// # Classes {#bdlar_accessorvtableutil-classes}
32///
33/// - bdlar::AccessorVtableUtil: ...
34///
35/// # Description {#bdlar_accessorvtableutil-description}
36/// This component provides ...
37///
38/// @}
39/** @} */
40/** @} */
41
42/** @addtogroup bdl
43 * @{
44 */
45/** @addtogroup bdlar
46 * @{
47 */
48/** @addtogroup bdlar_accessorvtableutil
49 * @{
50 */
51
52#include <bdlar_accessorvtable.h>
53#include <bdlar_simpletyperef.h>
54
55
56namespace bdlar {
57
58 // ========================
59 // class AccessorVtableUtil
60 // ========================
61
63 // PRIVATE CLASS METHODS
64
65 /// Invoke the specified accessor on the specified `ref`.
66 template <class t_ACCESSOR, class t_REF>
67 static int access(const void *accessorPtr, const t_REF& ref);
68
69 /// Invoke the specified accessor on the specified simple type `ref`.
70 template <class t_ACCESSOR>
71 static int accessSimple(const void *accessorPtr,
72 const SimpleTypeConstRef& ref);
73
74 /// Invoke the specified accessor on the specified simple type `ref` with
75 /// the specified `info`.
76 template <class t_ACCESSOR>
77 static int accessSimpleWithInfo(const void *accessorPtr,
78 const SimpleTypeConstRef& ref,
79 const FieldInfoRef& info);
80
81 /// Invoke the specified accessor on the specified `ref` with the specified
82 /// `info`.
83 template <class t_ACCESSOR, class t_REF>
84 static int accessWithInfo(const void *accessorPtr,
85 const t_REF& ref,
86 const FieldInfoRef& info);
87
88 public:
89 // CLASS METHODS
90
91 /// Construct and return a `AccessorVtable` object with a series of
92 /// function pointers that implement the accessors.
93 template <class t_ACCESSOR>
94 static const AccessorVtable *getVtable();
95
96 /// Construct and return a `AccessorWithInfoVtable` object with a series of
97 /// function pointers that implement the accessors.
98 template <class t_ACCESSOR>
100};
101
102// ============================================================================
103// INLINE DEFINITIONS
104// ============================================================================
105
106 // ------------------------
107 // class AccessorVtableUtil
108 // ------------------------
109
110// PRIVATE CLASS METHODS
111template <class t_ACCESSOR, class t_REF>
112int AccessorVtableUtil::access(const void *accessorPtr, const t_REF& ref)
113{
114 t_ACCESSOR& accessor = *reinterpret_cast<t_ACCESSOR *>(
115 const_cast<void *>(accessorPtr));
116 return accessor(ref);
117}
118
119template <class t_ACCESSOR>
120int AccessorVtableUtil::accessSimple(const void *accessorPtr,
121 const SimpleTypeConstRef& ref)
122{
123 return ref.access(*reinterpret_cast<t_ACCESSOR *>(
124 const_cast<void *>(accessorPtr)));
125}
126
127template <class t_ACCESSOR>
128int AccessorVtableUtil::accessSimpleWithInfo(
129 const void *accessorPtr,
130 const SimpleTypeConstRef& ref,
131 const FieldInfoRef& info)
132{
133 return ref.access(*reinterpret_cast<t_ACCESSOR *>(
134 const_cast<void *>(accessorPtr)),
135 info);
136}
137
138template <class t_ACCESSOR, class t_REF>
139int AccessorVtableUtil::accessWithInfo(const void *accessorPtr,
140 const t_REF& ref,
141 const FieldInfoRef& info)
142{
143 t_ACCESSOR& accessor = *reinterpret_cast<t_ACCESSOR *>(
144 const_cast<void *>(accessorPtr));
145 return accessor(ref, info);
146}
147
148// CLASS METHODS
149template <class t_ACCESSOR>
151{
152 static const AccessorVtable vtable = {
153 &access<t_ACCESSOR, DynamicTypeConstRef>,
154 &access<t_ACCESSOR, ArrayConstRef>,
155 &access<t_ACCESSOR, ChoiceConstRef>,
156 &access<t_ACCESSOR, CustomizedTypeConstRef>,
157 &access<t_ACCESSOR, EnumConstRef>,
158 &access<t_ACCESSOR, NullableValueConstRef>,
159 &access<t_ACCESSOR, SequenceConstRef>,
160 &accessSimple<t_ACCESSOR>
161 };
162 return &vtable;
163}
164
165template <class t_ACCESSOR>
167{
168 static const AccessorWithInfoVtable vtable = {
169 &accessWithInfo<t_ACCESSOR, DynamicTypeConstRef>,
170 &accessWithInfo<t_ACCESSOR, ArrayConstRef>,
171 &accessWithInfo<t_ACCESSOR, ChoiceConstRef>,
172 &accessWithInfo<t_ACCESSOR, CustomizedTypeConstRef>,
173 &accessWithInfo<t_ACCESSOR, EnumConstRef>,
174 &accessWithInfo<t_ACCESSOR, NullableValueConstRef>,
175 &accessWithInfo<t_ACCESSOR, SequenceConstRef>,
176 &accessSimpleWithInfo<t_ACCESSOR>
177 };
178 return &vtable;
179}
180
181} // close package namespace
182
183
184#endif
185
186// ----------------------------------------------------------------------------
187// Copyright 2024 Bloomberg Finance L.P.
188//
189// Licensed under the Apache License, Version 2.0 (the "License");
190// you may not use this file except in compliance with the License.
191// You may obtain a copy of the License at
192//
193// http://www.apache.org/licenses/LICENSE-2.0
194//
195// Unless required by applicable law or agreed to in writing, software
196// distributed under the License is distributed on an "AS IS" BASIS,
197// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
198// See the License for the specific language governing permissions and
199// limitations under the License.
200// ----------------------------- END-OF-FILE ----------------------------------
201
202/** @} */
203/** @} */
204/** @} */
Definition bdlar_accessorvtableutil.h:62
static const AccessorWithInfoVtable * getWithInfoVtable()
Definition bdlar_accessorvtableutil.h:166
static const AccessorVtable * getVtable()
Definition bdlar_accessorvtableutil.h:150
Definition bdlar_fieldinfo.h:102
Definition bdlar_simpletyperef.h:216
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bdlar_accessorref.h:59
reference_wrapper< T > ref(T &object)
Return a reference wrapper that represents the specified object.
Definition bdlar_accessorvtable.h:71
Definition bdlar_accessorvtable.h:102