μHAL (v2.7.9)
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 
50  mClientInterface ( aClientInterface ),
51  mNode ( aNode )
52  {
53  claimNode ( *mNode );
54  mClientInterface->mNode = mNode;
55  }
56 
57 
59  mClientInterface ( otherHw.mClientInterface ),
60  mNode ( otherHw.mNode->clone() )
61  {
62  claimNode ( *mNode );
63  mClientInterface->mNode = mNode;
64  }
65 
66 
68  {
69  }
70 
71 
72  void HwInterface::claimNode ( Node& aNode )
73  {
74  aNode.mHw = this;
75 
76  for ( std::vector< Node* >::iterator lIt = aNode.mChildren.begin(); lIt != aNode.mChildren.end(); ++lIt )
77  {
78  claimNode ( **lIt );
79  }
80  }
81 
82 
84  {
85  return *mClientInterface;
86  }
87 
88 
89  // void HwInterface::ping()
90  // {
91  // try
92  // {
93  // mClientInterface->ping();
94  // }
95  // catch ( uhal::exception& aExc )
96  // {
97  // aExc.throw r;
98  // }
99  // catch ( const std::exception& aExc )
100  // {
101  // throw // StdException ( aExc );
102  // }
103  // }
104 
105 
107  {
108  mClientInterface->dispatch ();
109  }
110 
111 
112  const std::string& HwInterface::id() const
113  {
114  return mClientInterface->id();
115  }
116 
117 
118  const std::string& HwInterface::uri() const
119  {
120  return mClientInterface->uri();
121  }
122 
123 
124  void HwInterface::setTimeoutPeriod ( const uint32_t& aTimeoutPeriod )
125  {
126  mClientInterface->setTimeoutPeriod ( aTimeoutPeriod );
127  }
128 
129 
131  {
132  return mClientInterface->getTimeoutPeriod();
133  }
134 
135  const Node& HwInterface::getNode () const
136  {
137  return *mNode;
138  }
139 
140 
141  const Node& HwInterface::getNode ( const std::string& aId ) const
142  {
143  return mNode->getNode ( aId );
144  }
145 
146 
147  std::vector<std::string> HwInterface::getNodes() const
148  {
149  return mNode->getNodes();
150  }
151 
152 
153  std::vector<std::string> HwInterface::getNodes ( const std::string& aRegex ) const
154  {
155  return mNode->getNodes ( aRegex );
156  }
157 
158 }
159 
160 
uhal::HwInterface
A class which bundles a node tree and an IPbus client interface together providing everything you nee...
Definition: HwInterface.hpp:61
boost::shared_ptr
Definition: DerivedNodeFactory.hpp:52
uhal::HwInterface::setTimeoutPeriod
void setTimeoutPeriod(const uint32_t &aTimeoutPeriod)
A method to modify the timeout period for any pending or future transactions.
Definition: HwInterface.cpp:124
uhal::Node::mHw
HwInterface * mHw
The parent hardware interface of which this node is a child (or rather decendent)
Definition: Node.hpp:334
Node.hpp
uhal::HwInterface::mClientInterface
boost::shared_ptr< ClientInterface > mClientInterface
A shared pointer to the IPbus client through which the transactions will be sent.
Definition: HwInterface.hpp:162
uhal::ClientInterface
An abstract base class for defining the interface to the various IPbus clients as well as providing t...
Definition: ClientInterface.hpp:100
boost
Definition: log.hpp:13
uhal::HwInterface::id
const std::string & id() const
Return the identifier of the target for this client.
Definition: HwInterface.cpp:112
uhal::HwInterface::HwInterface
HwInterface(const boost::shared_ptr< ClientInterface > &aClientInterface, const boost::shared_ptr< Node > &aNode)
Constructor.
Definition: HwInterface.cpp:49
uhal::HwInterface::dispatch
void dispatch()
Make the IPbus client issue a dispatch.
Definition: HwInterface.cpp:106
uhal::Node::mChildren
std::vector< Node * > mChildren
The direct children of the node.
Definition: Node.hpp:375
uhal::HwInterface::claimNode
void claimNode(Node &aNode)
A function which sets the HwInterface pointer in the Node to point to this HwInterface.
Definition: HwInterface.cpp:72
uhal
Definition: HttpResponseGrammar.hpp:49
uhal::HwInterface::mNode
boost::shared_ptr< Node > mNode
A node tree.
Definition: HwInterface.hpp:165
uhal::Node
A heirarchical node for navigating heirarchical firmwares.
Definition: Node.hpp:86
uhal::HwInterface::getTimeoutPeriod
uint32_t getTimeoutPeriod()
A method to retrieve the timeout period currently being used.
Definition: HwInterface.cpp:130
uhal::HwInterface::~HwInterface
virtual ~HwInterface()
Destructor.
Definition: HwInterface.cpp:67
uhal::HwInterface::getClient
ClientInterface & getClient()
Get the underlying IPbus client.
Definition: HwInterface.cpp:83
HwInterface.hpp
uhal::HwInterface::uri
const std::string & uri() const
Return the url of the target for this client.
Definition: HwInterface.cpp:118
uhal::HwInterface::getNodes
std::vector< std::string > getNodes() const
Return all node IDs known to this HwInterface.
Definition: HwInterface.cpp:147
uhal::HwInterface::getNode
const Node & getNode() const
Retrieve the top-level node.
Definition: HwInterface.cpp:135
ClientInterface.hpp