6#include "../internal/Conf.hpp"
10#include "../internal/Common.hpp"
27 ~SharedEntity()
noexcept override;
30
31
32
33
34
35 template <
typename T>
bool is()
const noexcept {
37 auto p =
dynamic_cast<
const T *>(
this);
42 }
catch (
const std::bad_cast &) {
48
49
50
51
52
53
54
55
56 template <
typename T> std::shared_ptr<T>
sharedAs()
noexcept {
57 return std::dynamic_pointer_cast<T>(shared_from_this());
61
62
63
64
65
66
67
68
69 template <
typename T> std::shared_ptr<T>
sharedAs()
const noexcept {
70 return std::dynamic_pointer_cast<T>(shared_from_this());
74
75
76
77
79 return "SharedEntity{}";
86
87
88
91 struct LockExternalConstructionTag {
92 explicit LockExternalConstructionTag() =
default;
97
98
99
100
101
102
104 static_assert(std::is_convertible_v<T *,
RequireMakeShared *>,
"Must derive publicly from RequireMakeShared");
106 return std::make_shared<T>(LockExternalConstructionTag{}, std::forward<Args>(args)...);
112template <
typename EBase, Derived<EBase> EDerived>
113static std::shared_ptr<EDerived> convertEvent(
const std::shared_ptr<EBase> &source) {
118 return source->
template sharedAs<EDerived>();
121template <
typename EBase, Derived<EBase> EDerived>
122static std::vector<std::shared_ptr<EDerived>> convertEvents(
const std::vector<std::shared_ptr<EBase>> &source) {
123 std::vector<std::shared_ptr<EDerived>> result{};
125 result.reserve(source.size());
127 for (
const auto &e : source) {
128 result.emplace_back(e->
template sharedAs<EDerived>());
#define DXFCXX_DISABLE_MSC_WARNINGS_POP()
Definition Conf.hpp:22
#define DXFCPP_END_NAMESPACE
Definition Conf.hpp:70
#define DXFCPP_BEGIN_NAMESPACE
Definition Conf.hpp:67
#define DXFCXX_DISABLE_GCC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:38
#define DXFCXX_DISABLE_GCC_WARNINGS_POP()
Definition Conf.hpp:40
#define DXFCXX_DISABLE_MSC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:21
#define DXFCPP_EXPORT
Definition api.h:35
Base abstract class for all dxFeed C++ API entities.
Definition Entity.hpp:13
Marks all event types that can be received via dxFeed API.
Definition EventType.hpp:31
A helper class needed to construct smart pointers to objects, and does not allow explicit constructio...
Definition SharedEntity.hpp:89
static auto createShared(Args &&...args)
Creates smart pointer to object.
Definition SharedEntity.hpp:103
Base abstract "shared entity" class. Has some helpers for dynamic polymorphism.
Definition SharedEntity.hpp:21
virtual std::string toString() const
Returns a string representation of the current object.
Definition SharedEntity.hpp:78
std::shared_ptr< T > sharedAs() const noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T.
Definition SharedEntity.hpp:69
std::shared_ptr< T > sharedAs() noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T.
Definition SharedEntity.hpp:56
bool is() const noexcept
Checks that pointer to the current type could be converted to type T* In other words: whether type T ...
Definition SharedEntity.hpp:35