BOSS 7.1.2
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/Precondition.h"
12#include "ers/NotImplemented.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}
26
27
29
31 for(unsigned int i=0;i<other.m_issue_queue.size();i++) {
32 Issue *cloned = other.m_issue_queue[i]->clone();
33 m_issue_queue.push_back(cloned);
34 } // for
35} // FIFOStream
36
38
39/** Sends the issue into the stream.
40 * This method should put the issue into a FIFO queue and be non blocking
41 * @param i pointer to the issue to send
42 * @note This method is not implemented, pending some form of common TDAQ thread library.
43 */
44
45void ers::FIFOStream::send(const ers::Issue *issue_ptr) {
46 ERS_PRE_CHECK_PTR(issue_ptr);
47 Issue *cloned = issue_ptr->clone();
48 m_issue_queue.push_back(cloned);
49} // send
50
51/** Blocking read into the stream.
52 * @return a reference to the next Issue
53 * @note This method is not implemented, pending some form of common TDAQ thread library.
54 */
55
57 if (m_issue_queue.empty()) return 0 ;
58 Issue *issue = m_issue_queue[0] ;
59 m_issue_queue.pop_front();
60 return issue ;
61} // receive
62
63void ers::FIFOStream::print_to(std::ostream& stream) const {
64 stream << ers::FIFOStream::FIFO_STREAM_KEY << ":[" ;
65 for(unsigned int i=0;i<m_issue_queue.size();i++) {
66 stream << m_issue_queue[i]->what() ;
67 if (i!=m_issue_queue.size()-1) {
68 stream << ", " ;
69 } // if not last
70 } // for elements
71 stream << "]" ;
72} // print_to
73
74
#define ERS_PRE_CHECK_PTR(p)
Queue stream.
Definition FIFOStream.h:22
std::deque< Issue * > m_issue_queue
Definition FIFOStream.h:25
virtual void send(const Issue *i)
virtual void print_to(std::ostream &stream) const
static const char *const FIFO_STREAM_KEY
Definition FIFOStream.h:27
virtual Issue * receive()
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.
Definition Stream.h:35