μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
HwInterface.cpp
Go to the documentation of this file.
1/*
2---------------------------------------------------------------------------
3
4 This file is part of uHAL.
5
6 uHAL is a hardware access library and programming framework
7 originally developed for upgrades of the Level-1 trigger of the CMS
8 experiment at CERN.
9
10 uHAL is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
14
15 uHAL is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with uHAL. If not, see <http://www.gnu.org/licenses/>.
22
23
24 Andrew Rose, Imperial College, London
25 email: awr01 <AT> imperial.ac.uk
26
27 Marc Magrans de Abril, CERN
28 email: marc.magrans.de.abril <AT> cern.ch
29
30---------------------------------------------------------------------------
31*/
32
33#include "uhal/HwInterface.hpp"
34
35
36#include <deque>
37#include <memory>
38
40#include "uhal/Node.hpp"
41
42
43namespace uhal
44{
45
46 HwInterface::HwInterface ( const std::shared_ptr<ClientInterface>& aClientInterface , const std::shared_ptr< Node >& aNode ) :
47 mClientInterface ( aClientInterface ),
48 mNode ( aNode )
49 {
50 claimNode ( *mNode );
51 mClientInterface->mNode = mNode;
52 }
53
54
56 mClientInterface ( otherHw.mClientInterface ),
57 mNode ( otherHw.mNode->clone() )
58 {
59 claimNode ( *mNode );
60 mClientInterface->mNode = mNode;
61 }
62
63
65 {
66 }
67
68
70 {
71 aNode.mHw = this;
72
73 for (Node* lChild: aNode.mChildren)
74 claimNode ( *lChild );
75 }
76
77
79 {
80 return *mClientInterface;
81 }
82
83
84 // void HwInterface::ping()
85 // {
86 // try
87 // {
88 // mClientInterface->ping();
89 // }
90 // catch ( uhal::exception& aExc )
91 // {
92 // aExc.throw r;
93 // }
94 // catch ( const std::exception& aExc )
95 // {
96 // throw // StdException ( aExc );
97 // }
98 // }
99
100
102 {
103 mClientInterface->dispatch ();
104 }
105
106
107 const std::string& HwInterface::id() const
108 {
109 return mClientInterface->id();
110 }
111
112
113 const std::string& HwInterface::uri() const
114 {
115 return mClientInterface->uri();
116 }
117
118
119 void HwInterface::setTimeoutPeriod ( const uint32_t& aTimeoutPeriod )
120 {
121 mClientInterface->setTimeoutPeriod ( aTimeoutPeriod );
122 }
123
124
126 {
127 return mClientInterface->getTimeoutPeriod();
128 }
129
130
132 {
133 return *mNode;
134 }
135
136
137 const Node& HwInterface::getNode ( const std::string& aId ) const
138 {
139 return mNode->getNode ( aId );
140 }
141
142
143 bool HwInterface::hasNode ( const std::string& aId ) const
144 {
145 return mNode->hasNode ( aId );
146 }
147
148
149 std::vector<std::string> HwInterface::getNodes() const
150 {
151 return mNode->getNodes();
152 }
153
154
155 std::vector<std::string> HwInterface::getNodes ( const std::string& aRegex ) const
156 {
157 return mNode->getNodes ( aRegex );
158 }
159
160}
161
162
An abstract base class for defining the interface to the various IPbus clients as well as providing t...
A class which bundles a node tree and an IPbus client interface together providing everything you nee...
Definition: HwInterface.hpp:56
std::vector< std::string > getNodes() const
Return all node IDs known to this HwInterface.
std::shared_ptr< ClientInterface > mClientInterface
A shared pointer to the IPbus client through which the transactions will be sent.
std::shared_ptr< Node > mNode
A node tree.
const Node & getNode() const
Retrieve the top-level node.
virtual ~HwInterface()
Destructor.
Definition: HwInterface.cpp:64
HwInterface(const std::shared_ptr< ClientInterface > &aClientInterface, const std::shared_ptr< Node > &aNode)
Constructor.
Definition: HwInterface.cpp:46
const std::string & id() const
Return the identifier of the target for this client.
void claimNode(Node &aNode)
A function which sets the HwInterface pointer in the Node to point to this HwInterface.
Definition: HwInterface.cpp:69
void dispatch()
Make the IPbus client issue a dispatch.
ClientInterface & getClient()
Get the underlying IPbus client.
Definition: HwInterface.cpp:78
bool hasNode(const std::string &aId) const
uint32_t getTimeoutPeriod()
A method to retrieve the timeout period currently being used.
const std::string & uri() const
Return the url of the target for this client.
void setTimeoutPeriod(const uint32_t &aTimeoutPeriod)
A method to modify the timeout period for any pending or future transactions.
A heirarchical node for navigating heirarchical firmwares.
Definition: Node.hpp:85
std::vector< Node * > mChildren
The direct children of the node.
Definition: Node.hpp:376
HwInterface * mHw
The parent hardware interface of which this node is a child (or rather decendent)
Definition: Node.hpp:335