ChimeraTK-DeviceAccess 03.27.00
Loading...
Searching...
No Matches
DeviceInfoMap.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 <boost/shared_ptr.hpp>
6
7#include <cstdint>
8#include <iostream>
9#include <list>
10#include <string>
11#include <vector>
12
13namespace ChimeraTK {
14
26 public:
30 class DeviceInfo {
31 public:
32 std::string deviceName;
33 std::string uri;
35 std::string mapFileName;
37 std::string dmapFileName;
44 DeviceInfo();
45
55 [[nodiscard]] std::pair<std::string, std::string> getDeviceFileAndMapFileName() const;
56
57 friend std::ostream& operator<<(std::ostream& os, const DeviceInfo& deviceInfo);
58 };
59
60 using iterator = std::vector<DeviceInfo>::iterator;
61 using const_iterator = std::vector<DeviceInfo>::const_iterator;
68 class ErrorList {
69 friend class DeviceInfoMap;
70
71 public:
78 class ErrorElem {
79 public:
87
95 enum class TYPE {
96 ERROR,
97 WARNING
98 };
99 using TYPE::ERROR;
100 using TYPE::WARNING;
118 ErrorElem(TYPE infoType, DMAP_FILE_ERR errorType, const DeviceInfoMap::DeviceInfo& device1,
119 const DeviceInfoMap::DeviceInfo& device2);
120 friend std::ostream& operator<<(std::ostream& os, const TYPE& me);
121 friend std::ostream& operator<<(std::ostream& os, const ErrorElem& me);
122 };
123 std::list<ErrorElem> _errors;
126 friend std::ostream& operator<<(std::ostream& os, const ErrorList& me);
127
128 private:
132 void clear();
137 void insert(const ErrorElem& elem);
138 };
154
155 friend std::ostream& operator<<(std::ostream& os, const DeviceInfoMap& deviceInfoMap);
165 void getDeviceInfo(const std::string& deviceName, DeviceInfo& value);
171 size_t getSize();
178 iterator begin();
179 [[nodiscard]] const_iterator begin() const;
186 iterator end();
187 [[nodiscard]] const_iterator end() const;
188
191 std::vector<std::string> getPluginLibraries();
192
195 void addPluginLibrary(const std::string& soFile);
196
197 protected:
198 std::vector<DeviceInfo> _deviceInfoElements;
199 std::string _dmapFileName;
200 std::vector<std::string> _pluginLibraries;
201
202 public:
211 explicit DeviceInfoMap(std::string fileName);
216 void insert(const DeviceInfo& elem);
217 };
223 using DeviceInfoMapPointer = boost::shared_ptr<DeviceInfoMap>;
224
225} // namespace ChimeraTK
Stores information about one device.
std::string uri
uri which describes the device (or name of the device file in /dev in backward compatibility mode)
DeviceInfo()
Default class constructor.
std::string dmapFileName
name of the DMAP file
std::string mapFileName
name of the MAP file storing information about PCIe registers mapping
uint32_t dmapFileLineNumber
line number in DMAP file storing listed above information
friend std::ostream & operator<<(std::ostream &os, const DeviceInfo &deviceInfo)
std::pair< std::string, std::string > getDeviceFileAndMapFileName() const
Convenience function to extract the device file name and the map file name as one object (a pair).
std::string deviceName
logical name of the device
Stores detailed information about one error or warning.
DMAP_FILE_ERR
Defines available types of detected problems.
@ NONUNIQUE_DEVICE_NAME
Names of two devices are the same - treated as critical error.
TYPE
Defines available classes of detected problems.
@ WARNING
Non-critical error was detected.
DMAP_FILE_ERR _errorType
Type of detected problem.
DeviceInfoMap::DeviceInfo _errorDevice1
Detailed information about first device that generate error or warning.
friend std::ostream & operator<<(std::ostream &os, const TYPE &me)
DeviceInfoMap::DeviceInfo _errorDevice2
Detailed information about second device that generate error or warning.
TYPE _type
Class of detected problem - ERROR or WARNING.
Stores information about errors and warnings.
friend std::ostream & operator<<(std::ostream &os, const ErrorList &me)
std::list< ErrorElem > _errors
Lists of errors or warnings detected during MAP file correctness checking.
std::vector< DeviceInfo > _deviceInfoElements
vector storing parsed contents of DMAP file
std::vector< std::string > _pluginLibraries
Names of the so files with the plugins.
bool check(ErrorList &err, ErrorList::ErrorElem::TYPE level)
Checks logical correctness of DMAP file.
friend std::ostream & operator<<(std::ostream &os, const DeviceInfoMap &deviceInfoMap)
void addPluginLibrary(const std::string &soFile)
Add the name of a library to the list.
void getDeviceInfo(const std::string &deviceName, DeviceInfo &value)
Returns information about specified device.
std::vector< DeviceInfo >::iterator iterator
const_iterator end() const
iterator end()
Return iterator to element after last one in DMAP file.
std::vector< DeviceInfo >::const_iterator const_iterator
size_t getSize()
Returns number of records in DMAP file.
void insert(const DeviceInfo &elem)
Insert new element read from DMAP file.
std::vector< std::string > getPluginLibraries()
You can define shared libraries with Backend plugins in the DMAP file.
std::string _dmapFileName
name of DMAP file
const_iterator begin() const
iterator begin()
Return iterator to first device described in DMAP file.
boost::shared_ptr< DeviceInfoMap > DeviceInfoMapPointer
Introduce specialisation of shared_pointer template for pointers to RegisterInfoMap object as a Devic...