Sen API
Sen Libraries
Toggle main menu visibility
Loading...
Searching...
No Matches
object_source.h
Go to the documentation of this file.
1
// === object_source.h =================================================================================================
2
// Sen Infrastructure
3
// Released under the Apache License v2.0 (SPDX-License-Identifier Apache-2.0).
4
// See the LICENSE.txt file for more information.
5
// © Airbus SAS, Airbus Helicopters, and Airbus Defence and Space SAU/GmbH/SAS.
6
// =====================================================================================================================
7
8
#ifndef SEN_CORE_OBJ_OBJECT_SOURCE_H
9
#define SEN_CORE_OBJ_OBJECT_SOURCE_H
10
11
// sen
12
#include "
sen/core/base/span.h
"
13
#include "
sen/core/meta/type_registry.h
"
14
#include "
sen/core/obj/object.h
"
15
#include "
sen/core/obj/object_filter.h
"
16
#include "
sen/core/obj/object_provider.h
"
17
18
// std
19
#include <mutex>
20
#include <vector>
21
22
namespace
sen::kernel::impl
23
{
24
class
Runner;
25
}
// namespace sen::kernel::impl
26
27
namespace
sen
28
{
29
32
34
class
ObjectSource
:
public
ObjectFilter
35
{
36
public
:
37
SEN_NOCOPY_NOMOVE(
ObjectSource
)
38
39
public
:
40
using
NativeObjectPtr
= std::shared_ptr<NativeObject>;
41
42
public
:
43
explicit
ObjectSource
(
const
ObjectOwnerId&
id
):
ObjectFilter
(id) {}
44
~ObjectSource
()
override
=
default
;
45
46
public
:
51
virtual
bool
add
(
const
Span<NativeObjectPtr>
& instances) = 0;
52
57
bool
add
(
NativeObjectPtr
instance) {
return
add
(
makeSpan<NativeObjectPtr>
(instance)); }
58
60
template
<
typename
T>
61
bool
add
(
const
std::vector<std::shared_ptr<T>>& instances)
62
{
63
std::vector<NativeObjectPtr> vec(instances.begin(), instances.end());
64
return
add
(
makeSpan
(vec));
65
}
66
70
virtual
void
remove
(
const
Span<NativeObjectPtr>
& instances) = 0;
71
75
void
remove
(
NativeObjectPtr
instance) {
remove
(
makeSpan<NativeObjectPtr>
(instance)); }
76
78
template
<
typename
T>
79
void
remove
(
const
std::vector<std::shared_ptr<T>>& instances)
80
{
81
std::vector<NativeObjectPtr> vec(instances.begin(), instances.end());
82
remove
(
makeSpan
(vec));
83
}
84
85
protected
:
86
friend
class
kernel::impl::Runner
;
87
virtual
void
flushOutputs
() = 0;
88
virtual
void
drainInputs
() = 0;
89
};
90
92
93
}
// namespace sen
94
95
#endif
// SEN_CORE_OBJ_OBJECT_SOURCE_H
sen::ObjectFilter::ObjectFilter
ObjectFilter(ObjectOwnerId ownerId)
sen::ObjectSource::Runner
friend class kernel::impl::Runner
Definition
object_source.h:86
sen::ObjectSource::drainInputs
virtual void drainInputs()=0
sen::ObjectSource::add
bool add(const std::vector< std::shared_ptr< T > > &instances)
Convenience helper.
Definition
object_source.h:61
sen::ObjectSource::flushOutputs
virtual void flushOutputs()=0
sen::ObjectSource::ObjectSource
ObjectSource(const ObjectOwnerId &id)
Definition
object_source.h:43
sen::ObjectSource::add
bool add(NativeObjectPtr instance)
Registers an object (including its type). It does nothing if the objects are already present....
Definition
object_source.h:57
sen::ObjectSource::remove
void remove(NativeObjectPtr instance)
Unregisters an object. Does nothing if the object is not present. This method is thread-safe.
Definition
object_source.h:75
sen::ObjectSource::~ObjectSource
~ObjectSource() override=default
sen::ObjectSource::remove
virtual void remove(const Span< NativeObjectPtr > &instances)=0
Unregisters an object and notifies any registered listeners. Ignores objects that are not present....
sen::ObjectSource::NativeObjectPtr
std::shared_ptr< NativeObject > NativeObjectPtr
Definition
object_source.h:40
sen::ObjectSource::add
virtual bool add(const Span< NativeObjectPtr > &instances)=0
Registers an object (including its type). It does nothing if the object is already registered....
sen::ObjectSource::remove
void remove(const std::vector< std::shared_ptr< T > > &instances)
Convenience helper.
Definition
object_source.h:79
sen::Span
Contiguous view of elements of type T. Inspired by http://www.open-std.org/jtc1/sc22/wg21/docs/papers...
Definition
span.h:34
sen::makeSpan
constexpr Span< T > makeSpan(T *ptr, std::size_t size) noexcept
Takes in a type that can be passed to a contiguous range and returns a Span.
Definition
span.h:201
sen
Definition
assert.h:17
object.h
object_filter.h
object_provider.h
span.h
type_registry.h
libs
core
include
sen
core
obj
object_source.h
Generated by
1.17.0