MAK Data Logger API Documentation for HLA
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
sharedQueue.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 ******************************************************************************/
5 
8 
9 #ifndef sharedQueue_H_
10 #define sharedQueue_H_
11 
12 #include <deque>
13 #include <lgrUtil/threadSafe.h>
14 #include <lgrUtil/collectors.h>
15 
16 namespace MAKLogger
17 {
18 
20  template <typename T>
22  {
23  public:
24 
25  DtSharedQueue() : myDeque(std::deque<T> ())
26  {
27  }
28 
29  DtSharedQueue(const DtSharedQueue& original)
30  {
31  *myDeque = *original.myDeque;
32  }
33 
34  int size() const
35  {
36  return static_cast<int>(myDeque->size());
37  }
38 
39  void clear()
40  {
41  myDeque->clear();
42  }
43 
44  void push(const T& input)
45  {
46  myDeque->push_back(input);
47  }
48 
49  void push_priority(const T& input)
50  {
51  myDeque->push_front(input);
52  }
53 
54  bool pop(T& output)
55  {
57  if(myDeque->empty() == false)
58  {
59  output = myDeque->front();
60  myDeque->pop_front();
61  return true;
62  }
63  return false;
64  }
65 
66  void move(DtCollector<T>& output)
67  {
71  typename std::deque<T>::iterator startIter = myDeque->begin();
72  typename std::deque<T>::iterator endIter = myDeque->end();
73  for(;startIter != endIter;++startIter)
74  {
75  output.collect(*startIter);
76  }
77  myDeque->clear();
78  }
79 
80  protected:
82  };
83 
84 }
85 
86 #endif
87 

Document ID: Generated on Thu Apr 7 20:50:59 EDT 2016 from SVN revision 163818
Copyright © 2005-2012 VT MÄK. All Rights Reserved (www.mak.com)