Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.27 KB | None | 0 0
  1. /*
  2.  * Copyright (C) 2001-2011 Jacek Sieka, arnetheduck on gmail point com
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify
  5.  * it under the terms of the GNU General Public License as published by
  6.  * the Free Software Foundation; either version 2 of the License, or
  7.  * (at your option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17.  */
  18.  
  19. #ifndef DCPLUSPLUS_WIN32_DEBUG_FRAME_H
  20. #define DCPLUSPLUS_WIN32_DEBUG_FRAME_H
  21.  
  22. #include "StaticFrame.h"
  23.  
  24. #include <dcpp/DebugManager.h>
  25. #include <dcpp/CriticalSection.h>
  26. #include <dcpp/Semaphore.h>
  27. #include <dcpp/Thread.h>
  28.  
  29. class DebugFrame : public StaticFrame<DebugFrame>,
  30.     private DebugManagerListener
  31. {
  32.     typedef StaticFrame<DebugFrame> BaseType;
  33. public:
  34.     enum Status {
  35.         STATUS_STATUS,
  36.         STATUS_LAST
  37.     };
  38.  
  39.     static const string id;
  40.     const string& getId() const;
  41.  
  42. private:
  43.     bool stop;
  44.     CriticalSection cs;
  45.     Semaphore s;
  46.     deque<string> cmdList;
  47.  
  48.     int run() {
  49.         setThreadPriority(Thread::LOW);
  50.         string x = Util::emptyString;
  51.         stop = false;
  52.  
  53.         while(true) {
  54.             s.wait();
  55.             if(stop)
  56.                 break;
  57.  
  58.             {
  59.                 Lock l(cs);
  60.                 if(cmdList.empty()) continue;
  61.  
  62.                 x = cmdList.front();
  63.                 cmdList.pop_front();
  64.             }
  65.             addLine(Text::toT(x));
  66.         }
  67.        
  68.         stop = false;
  69.         return 0;
  70.     }
  71.  
  72.     void addCmd(const string& cmd) {
  73.         {
  74.             Lock l(cs);
  75.             cmdList.push_back(cmd);
  76.         }
  77.         s.signal();
  78.     }
  79.  
  80.     friend class StaticFrame<DebugFrame>;
  81.     friend class MDIChildFrame<DebugFrame>;
  82.  
  83.     TextBoxPtr debug;
  84.  
  85.     DebugFrame(TabViewPtr parent);
  86.     virtual ~DebugFrame();
  87.  
  88.     void layout();
  89.     bool preClosing();
  90.  
  91.     void addLine(const tstring& msg);
  92.  
  93. //  bool handleContextMenu(const dwt::ScreenCoordinate& pt);
  94. //  bool handleDoubleClick(const dwt::MouseEvent& mouseEvent);
  95.  
  96.     // DebugManagerListener
  97.     virtual void on(DebugCommand, const string& message) throw();
  98.  
  99. };
  100.  
  101. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement