c97627954264da706e13a8f1da845e92ec52411a
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

1) /* Blinker
2)    Copyright 2011 Stefan Schuermans <stefan@blinkenarea.org>
3)    Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
4)    a blinkenarea.org project */
5) 
6) #include <list>
7) #include <string>
8) 
9) #include <BlinkenLib/BlinkenFrame.h>
10) 
11) #include "CallMgr.h"
12) #include "Directory.h"
13) #include "File.h"
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

14) #include "ListTracker.h"
15) #include "ListTracker_impl.h"
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

16) #include "Module.h"
17) #include "Priority.h"
18) #include "PriorityInput.h"
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

19) #include "OutStreamFile.h"
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

20) #include "StreamMgr.h"
21) #include "StreamRecv.h"
22) 
23) namespace Blinker {
24) 
25) /**
26)  * @brief constructor
27)  * @param[in] callMgr callback manager
28)  * @param[in] streamMgr stream manager
29)  * @param[in] dirBase base directory
30)  */
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

31) Priority::Priority(CallMgr &callMgr, StreamMgr &streamMgr,
32)                    const Directory &dirBase):
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

33)   Module(callMgr, streamMgr, dirBase),
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

34)   m_fileOutStream(dirBase.getFile("outstream"), streamMgr),
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

35)   m_inListTracker(*this, dirBase.getSubdir("inputs")),
36)   m_itCurIn(m_inListTracker.m_list.rend())
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

37) {
Stefan Schuermans add forgotten call to init...

Stefan Schuermans authored 12 years ago

38)   m_inListTracker.init();
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

39) }
40) 
41) /// virtual destructor
42) Priority::~Priority()
43) {
Stefan Schuermans add forgotten call to init...

Stefan Schuermans authored 12 years ago

44)   m_inListTracker.clear();
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

45) }
46) 
47) /// check for update of configuration
48) void Priority::updateConfig()
49) {
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

50)   // input list update
51)   m_inListTracker.updateConfig();
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

52) 
53)   // output stream name file was modified -> re-get output stream
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

54)   if (m_fileOutStream.checkModified())
55)     m_fileOutStream.update();
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

56) }
57) 
58) /**
59)  * @brief select specific input (called by inputs)
60)  * @param[in] input input to select
61)  */
62) void Priority::select(const Input *pInput)
63) {
64)   // search inputs for passed input
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

65)   m_itCurIn = m_inListTracker.m_list.rbegin();
66)   while (m_itCurIn != m_inListTracker.m_list.rend() &&
67)          m_itCurIn->m_pObj != pInput)
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

68)     ++m_itCurIn;
69) 
70)   // send current frame
71)   curFrame();
72) }
73) 
74) /// select lower priority input (called by inputs)
75) void Priority::selectLower()
76) {
77)   stBlinkenFrame *pFrame;
78) 
79)   // search inputs with lower priority until a frame is found
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

80)   while (m_itCurIn != m_inListTracker.m_list.rend()) {
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

81)     // check for frame
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

82)     if ((pFrame = m_itCurIn->m_pObj->getCurFrame())) {
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

83)       // frame found -> keep this input as current, send frame
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

84)       m_fileOutStream.setFrame(pFrame);
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

85)       return;
86)     }
87)     // try next input
88)     ++m_itCurIn;
89)   }
90) 
91)   // no input has got a frame -> send no frame
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

92)   m_fileOutStream.setFrame(NULL);
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

93) }
94) 
95) /// send current frame to output stream
96) void Priority::curFrame()
97) {
98)   stBlinkenFrame *pFrame;
99) 
100)   // current input available and frame it it available -> send frame
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

101)   if (m_itCurIn != m_inListTracker.m_list.rend() &&
102)       (pFrame = m_itCurIn->m_pObj->getCurFrame()))
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

103)     m_fileOutStream.setFrame(pFrame);
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

104)   // no frame available -> send this information
105)   else
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

106)     m_fileOutStream.setFrame(NULL);