BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Stream.cxx
Go to the documentation of this file.
1/*
2 * Stream.cxx
3 * ers
4 *
5 * Created by Matthias Wiesmann on 01.12.04.
6 * Copyright 2004 CERN. All rights reserved.
7 *
8 */
9
10#include <iostream>
11#include <sstream>
12
13#include "ers/Issue.h"
14#include "ers/StreamFactory.h"
15
16const char* const ers::Stream::NULL_STREAM_KEY = "null";
17
18namespace {
19 ers::Stream* create_stream( const std::string& protocol, const std::string& uri ) {
20 (void)uri;
21 if ( protocol == ers::Stream::NULL_STREAM_KEY ) return new ers::Stream();
22 return 0;
23 }
25 ers::Stream::NULL_STREAM_KEY, create_stream );
26} // anonymous namespace
27
28// --------------
29// Member methods
30// --------------
31
35
36ers::Stream::operator std::string() const {
37 std::ostringstream stream;
38 print_to( stream );
39 return stream.str();
40} // to string
41
42/** Sends the issue to the stream.
43 * \param i the issue to send
44 * \note This implementation silently discards the Issue
45 */
46
47void ers::Stream::send( const Issue* i ) { (void)i; } // send
48
49/** Reads an isssue on the stream
50 * \return the issue that has been read
51 * \note This implementation always returns a null pointer
52 */
53
54ers::Issue* ers::Stream::receive() { return 0; } // receive
55
56void ers::Stream::print_to( std::ostream& stream ) const {
57 stream << NULL_STREAM_KEY << ':';
58} // print_to
59
60std::ostream& ers::operator<<( std::ostream& target, const ers::Stream& s ) {
61 s.print_to( target );
62 return target;
63} // operator<<
XmlRpcServer s
Root Issue class.
bool register_factory(const std::string &name, create_stream_callback callback)
register a factory method
static StreamFactory * instance()
return the singleton
Root/Null issue stream.
virtual ~Stream()
Definition Stream.cxx:34
virtual void print_to(std::ostream &stream) const
Definition Stream.cxx:56
virtual void send(const Issue *i)
Sends an issue into the stream.
Definition Stream.cxx:47
virtual Issue * receive()
Receives an issue from the stream.
Definition Stream.cxx:54
static const char *const NULL_STREAM_KEY
std::ostream & operator<<(std::ostream &, const Issue &)