00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "chanwindow.h"
00020 #include "chanparse.h"
00021 #include "chanshare.h"
00022
00023 #include <notify.h>
00024
00025 WindowType* WindowDB = (WindowType*)0;
00026
00027 class WindowParseFunctor : public ChanParseFunctor {
00028 public:
00029 INLINE WindowParseFunctor(void) : ChanParseFunctor() {}
00030 virtual ~WindowParseFunctor(void);
00031
00032 virtual void operator()(std::string);
00033 };
00034
00035 WindowParseFunctor::~WindowParseFunctor(void) {
00036 return;
00037 }
00038
00039 void WindowParseFunctor::operator()(std::string S) {
00040 std::string sym;
00041
00042 ChanEatFrontWhite(S);
00043 sym = ChanReadNextWord(S);
00044 ChanCheckScoping(S);
00045 ChanDescope(S);
00046
00047
00048
00049
00050
00051 std::string layout = ChanReadNextWord(S);
00052 SetupSyms sv;
00053 PTA(int) cameraGroup;
00054 int group_index=0;
00055 {
00056 ChanCheckScoping(S);
00057 int i=ChanMatchingParen(S);
00058 std::string setupSubstring = S.substr(1,i-2);
00059 S.erase(0,i);
00060 ChanEatFrontWhite(setupSubstring);
00061
00062 while (!setupSubstring.empty()) {
00063
00064 ChanCheckScoping(setupSubstring);
00065 std::string groupSubstring = setupSubstring;
00066
00067 int iend = setupSubstring.find_first_of(")");
00068 groupSubstring = setupSubstring.substr(1,iend-1);
00069
00070 setupSubstring.erase(0,iend+1);
00071 ChanEatFrontWhite(setupSubstring);
00072
00073 while (!groupSubstring.empty()) {
00074
00075 int region_number = ChanReadNextInt(groupSubstring);
00076 if(region_number<0) {
00077 nout <<"Trying to read region index, which should be >= 0, ";
00078 nout << "but got "<<region_number<<"."<<endl;
00079 nout << "Ignoring this entry."<<endl;
00080 ChanReadNextWord(groupSubstring);
00081 } else {
00082
00083
00084
00085 while((int)sv.size() < region_number+1) {
00086 sv.push_back("");
00087 cameraGroup.push_back(0);
00088 }
00089 std::string stmp2 = ChanReadNextWord(groupSubstring);
00090 sv[region_number]=stmp2;
00091 cameraGroup[region_number]=group_index;
00092 }
00093 }
00094 group_index++;
00095 }
00096 }
00097 int X, Y;
00098 {
00099 ChanEatFrontWhite(S);
00100 ChanCheckScoping(S);
00101 int i = S.find_first_of(")");
00102 std::string screenSubstring = S.substr(1, i-1);
00103 S.erase(0, i+1);
00104 ChanEatFrontWhite(S);
00105 X = ChanReadNextInt(screenSubstring);
00106 Y = ChanReadNextInt(screenSubstring);
00107 }
00108 bool border = ChanReadNextBool(S);
00109 bool cursor = ChanReadNextBool(S);
00110
00111
00112 bool hw_chans = false;
00113 int hw_chan_offset = 0;
00114 bool dvr = false;
00115 if (!S.empty()) {
00116 hw_chan_offset = ChanReadNextInt(S);
00117 hw_chans = true;
00118 }
00119 if (!S.empty()) {
00120
00121 nout << "error, trailing text in window spec '" << S << "'" << endl;
00122 S.erase(0, std::string::npos);
00123 }
00124
00125 WindowItem W(hw_chans, dvr, hw_chan_offset, layout, sv, X, Y, border,
00126 cursor, cameraGroup);
00127
00128 if (chancfg_cat.is_debug()) {
00129 chancfg_cat->debug() << "parsed a window called '" << sym << "':" << endl;
00130 chancfg_cat->debug() << " do" << (W.getHWChans()?" ":" not ")
00131 << "use HW channels" << endl;
00132 chancfg_cat->debug() << " do" << (W.getDVR()?" ":" not ") << "use DVR"
00133 << endl;
00134 chancfg_cat->debug() << " do" << (W.getBorder()?" ":" not ")
00135 << "have a border" << endl;
00136 chancfg_cat->debug() << " do" << (W.getCursor()?" ":" not ")
00137 << "have a cursor" << endl;
00138 chancfg_cat->debug() << " HW channel offset: " << W.getChanOffset()
00139 << endl;
00140 chancfg_cat->debug() << " prefered window size: (" << W.getSizeX()
00141 << ", " << W.getSizeY() << ")" << endl;
00142 chancfg_cat->debug() << " layout: '" << W.getLayout() << "'" << endl;
00143 chancfg_cat->debug() << " setups:" << endl;
00144 SetupSyms q(W.getSetups());
00145 for (SetupSyms::iterator r=q.begin(); r!=q.end(); ++r)
00146 chancfg_cat->debug() << " '" << *r << "'" << endl;
00147 }
00148 (*WindowDB)[sym] = W;
00149 }
00150
00151 void ResetWindow() {
00152 if (WindowDB != (WindowType *)NULL) {
00153 delete WindowDB;
00154 }
00155 WindowDB = new WindowType;
00156 }
00157
00158 void ParseWindow(istream& is) {
00159 WindowParseFunctor w;
00160 ChanParse(is, &w);
00161 }