e3c00efb84473df3049cd97102b4e3b41740bdaa
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 <string>
7) 
8) #include <BlinkenLib/BlinkenFrame.h>
9) 
10) #include "Directory.h"
11) #include "File.h"
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

12) #include "InStreamFile.h"
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

13) #include "Priority.h"
14) #include "PriorityInput.h"
15) #include "StreamMgr.h"
16) #include "StreamRecv.h"
17) 
18) namespace Blinker {
19) 
20) /**
21)  * @brief constructor
22)  * @param[in] priority owning priority based selector
23)  * @param[in] name name of input (i.e. priority)
24)  * @param[in] dirBase base directory
25)  */
26) Priority::Input::Input(Priority &priority, const std::string &name,
27)                        const Directory &dirBase):
28)   m_priority(priority),
29)   m_name(name),
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

30)   m_fileInStream(dirBase.getFile("instream"), priority.m_streamMgr),
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

31)   m_pFrame(NULL)
32) {
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

33)   // set up
34)   m_fileInStream.setStreamRecv(this);
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

35) }
36) 
37) /// virtual destructor
38) Priority::Input::~Input()
39) {
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

40)   // clean up
41)   m_fileInStream.setStreamRecv(NULL);
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

42) }
43) 
44) /// check for update of configuration
45) void Priority::Input::updateConfig()
46) {
47)   // input stream name file was modified -> re-get input stream
48)   if (m_fileInStream.checkModified()) {
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

49)     frame(NULL); // unset frame to force priority reevalulation
50)     m_fileInStream.update();
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

51)   }
52) }
53) 
54) /**
55)  * @brief set current frame
56)  * @param[in] stream stream name
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

57)  * @param[in] pFrame current frame (NULL for none)
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

58)  */
Stefan Schuermans 80 char reformatting

Stefan Schuermans authored 12 years ago

59) void Priority::Input::setFrame(const std::string &stream,
60)                                stBlinkenFrame *pFrame)
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

61) {
62)   frame(pFrame);
63)   (void)stream; // unused
64) }
65) 
66) /**
67)  * @brief get current frame
Stefan Schuermans simplified interface of get...

Stefan Schuermans authored 12 years ago

68)  * @return current frame (NULL if none)
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

69)  */
Stefan Schuermans simplified interface of get...

Stefan Schuermans authored 12 years ago

70) stBlinkenFrame * Priority::Input::getCurFrame()
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

71) {
Stefan Schuermans simplified interface of get...

Stefan Schuermans authored 12 years ago

72)   return m_pFrame;
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

73) }
74) 
75) /**
76)  * @brief set current frame
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

77)  * @param[in] pFrame current frame (NULL for none)
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

78)  */
79) void Priority::Input::frame(stBlinkenFrame *pFrame)
80) {
81)   // save new frame
82)   m_pFrame = pFrame;
83) 
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

84)   // there is a frame now
85)   if (pFrame) {
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

86) 
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

87)     // if we are current input
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

88)     if (m_priority.m_itCurIn != m_priority.m_inListTracker.m_list.rend() &&
89)         m_priority.m_itCurIn->m_pObj == this)
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

90)       // pass on frame
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

91)       m_priority.m_fileOutStream.setFrame(pFrame);
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

92) 
93)     // we have a higher priority than current input
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

94)     if (m_priority.m_itCurIn == m_priority.m_inListTracker.m_list.rend() ||
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

95)         m_priority.m_itCurIn->m_name < m_name)
96)       // tell priority based selector to select us as input
97)       m_priority.select(this);
98) 
99)   }
100)   // there is no frame
101)   else {
102) 
103)     // if we are current input
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

104)     if (m_priority.m_itCurIn != m_priority.m_inListTracker.m_list.rend() &&
105)         m_priority.m_itCurIn->m_pObj == this)
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

106)       // tell priority based selector to select lower priority input
107)       m_priority.selectLower();
108) 
109)   }