ChimeraTK-ApplicationCore 04.06.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
9#include "PyTransferElement.h"
10#include "ScalarAccessor.h"
11
12#include <ChimeraTK/VariantUserTypes.h>
13
14namespace py = pybind11;
15
16namespace ChimeraTK {
17
18 /********************************************************************************************************************/
19
20 class PyScalarAccessor : public PyTransferElement<PyScalarAccessor>, public PyOwnedObject {
21 // Helper for constructor - note: we can move templates to the .cc file if we use them only in the same .cc file
22 template<template<typename> class AccessorType>
23 static UserTypeTemplateVariantNoVoid<ScalarAccessor> createAccessor(ChimeraTK::DataType type, Module* owner,
24 const std::string& name, const std::string& unit, const std::string& description,
25 const std::unordered_set<std::string>& tags);
26
27 public:
29
30 template<template<typename> class AccessorType>
31 PyScalarAccessor(AccessorTypeTag<AccessorType>, ChimeraTK::DataType type, Module* owner, const std::string& name,
32 const std::string& unit, const std::string& description, const std::unordered_set<std::string>& tags = {});
33
35
37
38 UserTypeVariantNoVoid readAndGet();
39
40 UserTypeVariantNoVoid get() const;
41
42 void writeIfDifferent(UserTypeVariantNoVoid val);
43
44 void setAndWrite(UserTypeVariantNoVoid val);
45
46 void set(UserTypeVariantNoVoid val);
47
48 static std::string repr(py::object& acc);
49
50 static void bind(py::module& mod);
51
52 // Needs to be mutable to have a const get function, despite a non-const getHighLevelImplElement function
53 // get has to be const so it can be used in operator== which is expected by pibind11 to have const arguments.
54 mutable UserTypeTemplateVariantNoVoid<ScalarAccessor> _accessor;
55 };
56
57 /********************************************************************************************************************/
58
59} // 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)
UserTypeTemplateVariantNoVoid< ScalarAccessor > _accessor
UserTypeVariantNoVoid get() const
InvalidityTracer application module.
module_ module