ChimeraTK-DeviceAccess  03.18.00
MuxedInterruptDistributor.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 "../VersionNumber.h"
6 
7 #include <boost/enable_shared_from_this.hpp>
8 #include <boost/shared_ptr.hpp>
9 
10 #include <functional>
11 #include <map>
12 #include <memory>
13 #include <vector>
14 
15 namespace ChimeraTK {
16  class DeviceBackend;
17 } // namespace ChimeraTK
18 
19 namespace ChimeraTK::async {
20  class MuxedInterruptDistributor;
21  class AsyncAccessorManager;
22  template<typename BackendSpecificDataType>
23  class SubDomain;
24  class Domain;
25 
26  /********************************************************************************************************************/
27 
29  public:
31  boost::shared_ptr<MuxedInterruptDistributor> createMuxedInterruptDistributor(
32  boost::shared_ptr<SubDomain<std::nullptr_t>> parent);
33 
34  protected:
37  std::map<std::string,
38  std::function<std::unique_ptr<MuxedInterruptDistributor>(
39  std::string, boost::shared_ptr<SubDomain<std::nullptr_t>>)>>
41  static std::unique_ptr<MuxedInterruptDistributorFactory> _instance;
42 
43  static std::pair<std::string, std::string> getInterruptControllerNameAndDescriptionFromCatalogue(
44  std::vector<size_t> const& subdomainID, DeviceBackend& backend);
45 
46  private:
48  };
49 
50  /********************************************************************************************************************/
51 
56  class MuxedInterruptDistributor : public boost::enable_shared_from_this<MuxedInterruptDistributor> {
57  public:
61  explicit MuxedInterruptDistributor(boost::shared_ptr<SubDomain<std::nullptr_t>> parent);
62  virtual ~MuxedInterruptDistributor() = default;
63 
69  template<typename DistributorType>
70  [[nodiscard]] boost::shared_ptr<AsyncAccessorManager> getAccessorManager(
71  std::vector<size_t> const& qualififedSubDomainId);
72 
73  virtual void activate(VersionNumber version);
74  void sendException(const std::exception_ptr& e);
75 
79  virtual void handle(VersionNumber version) = 0;
80 
81  protected:
82  std::map<size_t, boost::weak_ptr<SubDomain<std::nullptr_t>>> _subDomains;
83 
84  boost::shared_ptr<DeviceBackend> _backend;
85 
88  std::vector<size_t> _id;
89 
90  boost::shared_ptr<SubDomain<std::nullptr_t>> _parent;
91  boost::shared_ptr<Domain> _asyncDomain;
92 
98  virtual void activateSubDomain(SubDomain<std::nullptr_t>& subDomain, VersionNumber const& version);
99  };
100 
101  /********************************************************************************************************************/
102 
103 } // namespace ChimeraTK::async
ChimeraTK::async::MuxedInterruptDistributorFactory
Definition: MuxedInterruptDistributor.h:28
ChimeraTK::async::MuxedInterruptDistributor::handle
virtual void handle(VersionNumber version)=0
The interrupt handling functions implements the handshake with the interrupt controller.
ChimeraTK::async::MuxedInterruptDistributor::sendException
void sendException(const std::exception_ptr &e)
Definition: MuxedInterruptDistributor.cc:134
ChimeraTK::async::MuxedInterruptDistributorFactory::createMuxedInterruptDistributor
boost::shared_ptr< MuxedInterruptDistributor > createMuxedInterruptDistributor(boost::shared_ptr< SubDomain< std::nullptr_t >> parent)
Definition: MuxedInterruptDistributor.cc:68
ChimeraTK::async::SubDomain
Send backend-specific asynchronous data to different distributors:
Definition: MuxedInterruptDistributor.h:23
ChimeraTK::async::MuxedInterruptDistributorFactory::getInstance
static MuxedInterruptDistributorFactory & getInstance()
Definition: MuxedInterruptDistributor.cc:27
ChimeraTK::async::MuxedInterruptDistributor::MuxedInterruptDistributor
MuxedInterruptDistributor(boost::shared_ptr< SubDomain< std::nullptr_t >> parent)
MuxedInterruptDistributor classes must only be constructed inside and held by a DeviceBackend,...
Definition: MuxedInterruptDistributor.cc:81
ChimeraTK::async
Definition: design_AsyncNDRegisterAcessor_and_NumericAddressedBackend.dox:1
ChimeraTK::async::MuxedInterruptDistributor::_id
std::vector< size_t > _id
The ID of this controller handler.
Definition: MuxedInterruptDistributor.h:88
ChimeraTK::async::MuxedInterruptDistributor::getAccessorManager
boost::shared_ptr< AsyncAccessorManager > getAccessorManager(std::vector< size_t > const &qualififedSubDomainId)
Get an AsyncAccessorManager of type DistributorType from the matching SubDomain.
Definition: MuxedInterruptDistributor.cc:87
ChimeraTK::async::MuxedInterruptDistributorFactory::_creatorFunctions
std::map< std::string, std::function< std::unique_ptr< MuxedInterruptDistributor > std::string, boost::shared_ptr< SubDomain< std::nullptr_t > >)> > _creatorFunctions
Each controller type is registered via name and creator function.
Definition: MuxedInterruptDistributor.h:40
ChimeraTK::DeviceBackend
The base class for backends providing IO functionality for the Device class.
Definition: DeviceBackend.h:28
ChimeraTK::async::MuxedInterruptDistributor::_asyncDomain
boost::shared_ptr< Domain > _asyncDomain
Definition: MuxedInterruptDistributor.h:91
ChimeraTK::async::MuxedInterruptDistributorFactory::getInterruptControllerNameAndDescriptionFromCatalogue
static std::pair< std::string, std::string > getInterruptControllerNameAndDescriptionFromCatalogue(std::vector< size_t > const &subdomainID, DeviceBackend &backend)
Definition: MuxedInterruptDistributor.cc:35
ChimeraTK::async::MuxedInterruptDistributor
Interface base class for interrupt controller handlers.
Definition: MuxedInterruptDistributor.h:56
ChimeraTK::async::MuxedInterruptDistributorFactory::_instance
static std::unique_ptr< MuxedInterruptDistributorFactory > _instance
Definition: MuxedInterruptDistributor.h:41
ChimeraTK::VersionNumber
Class for generating and holding version numbers without exposing a numeric representation.
Definition: VersionNumber.h:23
ChimeraTK::async::MuxedInterruptDistributor::activateSubDomain
virtual void activateSubDomain(SubDomain< std::nullptr_t > &subDomain, VersionNumber const &version)
Function to activate a (new) single SubDomain if the MuxedInterruptDistributor is already active.
Definition: MuxedInterruptDistributor.cc:144
ChimeraTK::async::MuxedInterruptDistributor::_parent
boost::shared_ptr< SubDomain< std::nullptr_t > > _parent
Definition: MuxedInterruptDistributor.h:90
ChimeraTK::async::MuxedInterruptDistributor::~MuxedInterruptDistributor
virtual ~MuxedInterruptDistributor()=default
ChimeraTK::async::MuxedInterruptDistributor::_backend
boost::shared_ptr< DeviceBackend > _backend
Definition: MuxedInterruptDistributor.h:84
ChimeraTK::async::Domain
The Domain is the thread-safe entry point for each distribution tree.
Definition: Domain.h:25
ChimeraTK
Definition: DummyBackend.h:16
ChimeraTK::async::MuxedInterruptDistributor::activate
virtual void activate(VersionNumber version)
Definition: MuxedInterruptDistributor.cc:124
ChimeraTK::async::MuxedInterruptDistributor::_subDomains
std::map< size_t, boost::weak_ptr< SubDomain< std::nullptr_t > > > _subDomains
Definition: MuxedInterruptDistributor.h:82