ChimeraTK-ApplicationCore 04.08.00
Loading...
Searching...
No Matches
PyScalarAccessor.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3#pragma once
4
5#include <pybind11/pybind11.h>
6// pybind11.h must come first
7
8#include "AccessorVariant.h"
10#include "PyTransferElement.h"
11
12namespace py = pybind11;
13
14namespace ChimeraTK {
15
16 /********************************************************************************************************************/
17
18 class PyScalarAccessor : public PyTransferElement<PyScalarAccessor>, public PyOwnedObject {
19 // Helper for constructor - note: we can move templates to the .cc file if we use them only in the same .cc file
20 template<template<typename> class AccessorType>
21 static ScalarAccessorVariant createAccessor(ChimeraTK::DataType type, Module* owner, const std::string& name,
22 const std::string& unit, const std::string& description, const std::unordered_set<std::string>& tags);
23
24 public:
26
27 template<template<typename> class AccessorType>
28 PyScalarAccessor(AccessorTypeTag<AccessorType>, ChimeraTK::DataType type, Module* owner, const std::string& name,
29 const std::string& unit, const std::string& description, const std::unordered_set<std::string>& tags = {});
30
32
34
35 UserTypeVariantNoVoid readAndGet();
36
37 UserTypeVariantNoVoid get() const;
38
39 void writeIfDifferent(UserTypeVariantNoVoid val);
40
41 void setAndWrite(UserTypeVariantNoVoid val);
42
43 void set(UserTypeVariantNoVoid val);
44
45 static std::string repr(py::object& acc);
46
47 static void bind(py::module& mod);
48
49 // Needs to be mutable to have a const get function, despite a non-const getHighLevelImplElement function
50 // get has to be const so it can be used in operator== which is expected by pibind11 to have const arguments.
52 };
53
54 /********************************************************************************************************************/
55
56} // namespace ChimeraTK
Base class for ApplicationModule and DeviceModule, to have a common interface for these module types.
Definition Module.h:21
Base class used for all objects in the Python world which can be owned by another object.
void set(UserTypeVariantNoVoid val)
void writeIfDifferent(UserTypeVariantNoVoid val)
static std::string repr(py::object &acc)
UserTypeVariantNoVoid readAndGet()
static void bind(py::module &mod)
PyScalarAccessor(PyScalarAccessor &&)=default
void setAndWrite(UserTypeVariantNoVoid val)
ScalarAccessorVariant _accessor
UserTypeVariantNoVoid get() const
InvalidityTracer application module.
typename detail::NestedVariant< UserTypeTemplateVariantNoVoid< ScalarAccessor >, UserTypeTemplateVariantNoVoid< ScalarPollInput >, UserTypeTemplateVariantNoVoid< ScalarPushInput >, UserTypeTemplateVariantNoVoid< ScalarOutput >, UserTypeTemplateVariantNoVoid< ScalarPushInputWB >, UserTypeTemplateVariantNoVoid< ScalarOutputPushRB >, UserTypeTemplateVariantNoVoid< ScalarOutputReverseRecovery >, UserTypeTemplateVariantNoVoid< ScalarPushInputNoInitialValue >, UserTypeTemplateVariantNoVoid< ScalarPollInputNoInitialValue > >::type ScalarAccessorVariant
All concrete scalar accessor types used by the Python bindings.
module_ module