Mantid
Loading...
Searching...
No Matches
LiveListenerInfo.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7//----------------------------------------------------------------------
8// Includes
9//----------------------------------------------------------------------
11
13#include "MantidKernel/Logger.h"
14
15#include <Poco/DOM/Element.h>
16
17#include <ostream>
18#include <utility>
19
20namespace Mantid::Kernel {
21namespace {
22// static logger object
23Logger g_log("InstrumentInfo");
24} // namespace
25
32LiveListenerInfo::LiveListenerInfo(InstrumentInfo *inst, const Poco::XML::Element *elem)
33 : m_name(elem->getAttribute("name")), m_address(elem->getAttribute("address")),
34 m_listener(elem->getAttribute("listener")) {
35
36 if (m_name.empty())
37 g_log.error() << "Listener connection name for " << inst->name()
38 << "is not defined. This listener will not be selectable.\n";
39 if (m_address.empty())
40 g_log.error() << "Listener address for " << inst->name() << " is not defined.\n";
41 if (m_listener.empty())
42 g_log.error() << "Listener class for " << inst->name() << " is not defined.\n";
43}
44
52LiveListenerInfo::LiveListenerInfo(std::string listener, std::string address, std::string name)
53 : m_name(std::move(name)), m_address(std::move(address)), m_listener(std::move(listener)) {}
54
56 return (this->address() == rhs.address() && this->listener() == rhs.listener());
57}
58
59const std::string &LiveListenerInfo::name() const { return m_name; }
60
61const std::string &LiveListenerInfo::address() const { return m_address; }
62
63const std::string &LiveListenerInfo::listener() const { return m_listener; }
64
65//-------------------------------------------------------------------------
66// Non-member functions
67//-------------------------------------------------------------------------
75std::ostream &operator<<(std::ostream &buffer, const LiveListenerInfo &listener) {
76 buffer << listener.name() << "(" << listener.address() << ", " << listener.listener() << ")";
77 return buffer;
78}
79
80} // namespace Mantid::Kernel
const std::vector< double > & rhs
A class that holds information about an instrument.
const std::string name() const
Return the name of the instrument.
A class that holds information about a LiveListener connection.
std::string m_address
Listener address.
LiveListenerInfo(InstrumentInfo *inst, const Poco::XML::Element *elem)
Construct from Facility Info XML.
const std::string & name() const
Return the name of this LiveListener connection.
std::string m_name
Listener name.
bool operator==(const LiveListenerInfo &rhs) const
Required for Python bindings.
std::string m_listener
Listener classname.
const std::string & address() const
Returns the address string of this LiveListener connection.
const std::string & listener() const
Returns the classname of the specific LiveListener to use.
void error(const std::string &msg)
Logs at error level.
Definition: Logger.cpp:77
MANTID_KERNEL_DLL std::ostream & operator<<(std::ostream &, CPUTimer &)
Convenience function to provide for easier debug printing.
Definition: CPUTimer.cpp:86
STL namespace.