μHAL (v2.6.5)
Part of the IPbus software repository
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 
38 #include "uhal/ClientInterface.hpp"
39 #include "uhal/Node.hpp"
40 
41 
42 namespace boost {
43  template <class Y> class shared_ptr;
44 }
45 
46 namespace uhal
47 {
48 
49  HwInterface::HwInterface ( const boost::shared_ptr<ClientInterface>& aClientInterface , const boost::shared_ptr< Node >& aNode ) :
50  mClientInterface ( aClientInterface ),
51  mNode ( aNode )
52  {
53  claimNode ( *mNode );
54  }
55 
56 
59  mNode ( otherHw.mNode->clone() )
60  {
61  claimNode ( *mNode );
62  }
63 
64 
66  {
67  }
68 
69  void HwInterface::claimNode ( Node& aNode )
70  {
71  aNode.mHw = this;
72 
73  for ( std::deque< Node* >::iterator lIt = aNode.mChildren.begin(); lIt != aNode.mChildren.end(); ++lIt )
74  {
75  claimNode ( **lIt );
76  }
77  }
78 
80  {
81  return *mClientInterface;
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 
101  {
102  mClientInterface->dispatch ();
103  }
104 
105 
106  const std::string& HwInterface::id() const
107  {
108  return mClientInterface->id();
109  }
110 
111 
112  std::string HwInterface::uri() const
113  {
114  return mClientInterface->uri();
115  }
116 
117 
118  void HwInterface::setTimeoutPeriod ( const uint32_t& aTimeoutPeriod )
119  {
120  mClientInterface->setTimeoutPeriod ( aTimeoutPeriod );
121  }
122 
123 
125  {
126  return mClientInterface->getTimeoutPeriod();
127  }
128 
129  const Node& HwInterface::getNode () const
130  {
131  return *mNode;
132  }
133 
134 
135  const Node& HwInterface::getNode ( const std::string& aId ) const
136  {
137  return mNode->getNode ( aId );
138  }
139 
140  std::vector<std::string> HwInterface::getNodes() const
141  {
142  return mNode->getNodes();
143  }
144 
145  std::vector<std::string> HwInterface::getNodes ( const std::string& aRegex ) const
146  {
147  return mNode->getNodes ( aRegex );
148  }
149 
150  // ValVector< uint32_t > HwInterface::readReservedAddressInfo ()
151  // {
152  // try
153  // {
154  // return mClientInterface->readReservedAddressInfo();
155  // }
156  // catch ( uhal::exception& aExc )
157  // {
158  // aExc.rethrowFrom( ThisLocation() );
159  // }
160  // catch ( const std::exception& aExc )
161  // {
162  // log ( Error() , "Exception " , Quote ( aExc.what() ) , " caught at " , ThisLocation() ); // uhal::StdException lExc( aExc );
163  // lExc.throwFrom( ThisLocation() );
164  // }
165  // }
166 
167 }
168 
169 
HwInterface * mHw
The parent hardware interface of which this node is a child (or rather decendent) ...
Definition: Node.hpp:337
A class which bundles a node tree and an IPbus client interface together providing everything you nee...
Definition: HwInterface.hpp:59
std::string uri() const
Return the url of the target for this client.
void dispatch()
Make the IPbus client issue a dispatch.
A heirarchical node for navigating heirarchical firmwares.
Definition: Node.hpp:83
std::deque< Node *> mChildren
The direct children of the node.
Definition: Node.hpp:378
ClientInterface & getClient()
Get the underlying IPbus client.
Definition: HwInterface.cpp:79
std::vector< std::string > getNodes() const
Return all node IDs known to this HwInterface.
void setTimeoutPeriod(const uint32_t &aTimeoutPeriod)
A method to modify the timeout period for any pending or future transactions.
An abstract base class for defining the interface to the various IPbus clients as well as providing t...
HwInterface(const boost::shared_ptr< ClientInterface > &aClientInterface, const boost::shared_ptr< Node > &aNode)
Constructor.
Definition: HwInterface.cpp:49
void claimNode(Node &aNode)
Get the target device&#39;s reserved address information.
Definition: HwInterface.cpp:69
boost::shared_ptr< ClientInterface > mClientInterface
A shared pointer to the IPbus client through which the transactions will be sent. ...
boost::shared_ptr< Node > mNode
A node tree.
const Node & getNode() const
Ping the target for this client.
const std::string & id() const
Return the identifier of the target for this client.
uint32_t getTimeoutPeriod()
A method to retrieve the timeout period currently being used.
virtual ~HwInterface()
Destructor.
Definition: HwInterface.cpp:65