BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
FIFOStream.cxx
Go to the documentation of this file.
1/*
2 * FIFOStream.cxx
3 * ers
4 *
5 * Created by Matthias Wiesmann on 02.12.04.
6 * Copyright 2004 CERN. All rights reserved.
7 *
8 */
9
10#include "ers/FIFOStream.h"
11#include "ers/InvalidReferenceIssue.h"
12#include "ers/NotImplemented.h"
13#include "ers/Precondition.h"
14#include "ers/StreamFactory.h"
15
16const char* const ers::FIFOStream::FIFO_STREAM_KEY = "fifo";
17
18namespace {
19 ers::Stream* create_stream( const std::string& protocol, const std::string& uri ) {
20 (void)uri; // to shut up the compiler
21 if ( protocol == ers::FIFOStream::FIFO_STREAM_KEY ) return new ers::FIFOStream();
22 return 0;
23 }
25 ers::FIFOStream::FIFO_STREAM_KEY, create_stream );
26} // namespace
27
29
30ers::FIFOStream::FIFOStream( const FIFOStream& other ) : Stream( other ) {
31 for ( unsigned int i = 0; i < other.m_issue_queue.size(); i++ )
32 {
33 Issue* cloned = other.m_issue_queue[i]->clone();
34 m_issue_queue.push_back( cloned );
35 } // for
36} // FIFOStream
37
39
40/** Sends the issue into the stream.
41 * This method should put the issue into a FIFO queue and be non blocking
42 * @param i pointer to the issue to send
43 * @note This method is not implemented, pending some form of common TDAQ thread library.
44 */
45
46void ers::FIFOStream::send( const ers::Issue* issue_ptr ) {
47 ERS_PRE_CHECK_PTR( issue_ptr );
48 Issue* cloned = issue_ptr->clone();
49 m_issue_queue.push_back( cloned );
50} // send
51
52/** Blocking read into the stream.
53 * @return a reference to the next Issue
54 * @note This method is not implemented, pending some form of common TDAQ thread library.
55 */
56
58 if ( m_issue_queue.empty() ) return 0;
59 Issue* issue = m_issue_queue[0];
60 m_issue_queue.pop_front();
61 return issue;
62} // receive
63
64void ers::FIFOStream::print_to( std::ostream& stream ) const {
65 stream << ers::FIFOStream::FIFO_STREAM_KEY << ":[";
66 for ( unsigned int i = 0; i < m_issue_queue.size(); i++ )
67 {
68 stream << m_issue_queue[i]->what();
69 if ( i != m_issue_queue.size() - 1 ) { stream << ", "; } // if not last
70 } // for elements
71 stream << "]";
72} // print_to
static const char *const FIFO_STREAM_KEY
virtual void send(const Issue *i)
std::deque< Issue * > m_issue_queue
virtual void print_to(std::ostream &stream) const
virtual Issue * receive()
Root Issue class.
Issue * clone() const
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.