⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tracetool.h.svn-base

📁 股票软件源码
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
   // Plugin API. not available on pocket PC
   #ifndef _WIN32_WCE
   void CreateResource  (const int ResId    , const int ResType ,                // Create a resource on the window
                         const int ResWidth , const char * ResText = NULL) ;   
   void CreateResource  (const int ResId    , const int ResType ,                // Create a resource on the window
                         const int ResWidth , const wchar_t * ResText = NULL) ;   
   void DisableResource (const int ResId) ;                                      // Disable tracetool or user created resources
   void SetTextResource (const int ResId, const char    * ResText) ;             // Set the resource text
   void SetTextResource (const int ResId, const wchar_t * ResText) ;             // Set the resource text
   void LinkToPlugin    (const char   * PluginName,  const int flags) ;          // Attach a winTrace to a plugin
   void LinkToPlugin    (const wchar_t * PluginName, const int flags) ;          // Attach a winTrace to a plugin
   #endif
} ;

//====================================================================================

/// <summary>
/// WinTrace represent a windows tree where you put watches
/// </summary>

class WinWatch
{
public :
   string id ; 	                                                   // Wintrace id (empty for the main window)
   bool   enabled ;                                                  // enable or disable watches
   int    tag ;                                                      // User defined tag, NOT SEND to the viewer

   WinWatch (void) ;
   WinWatch (const char    * WinWatchID , const char    * WinWatchText) ;
   WinWatch (const wchar_t * WinWatchID , const wchar_t * WinWatchText) ;
   void DisplayWin (void) ;
   void ClearAll (void) ;
   void Send (const char    * WatchName , const char    * WatchValue) ;
   void Send (const wchar_t * WatchName , const wchar_t * WatchValue) ;
} ;

//====================================================================================

/// <summary>
/// TTrace is the entry point for all traces.
/// TTrace give 3 'TraceNode' doors : Warning , Error and Debug.
/// Theses 3 doors are displayed with a special icon (all of them have the 'enabled' property set to true.
/// That class is fully static.
/// </summary>

class TTrace    
{
   friend TraceOptions ;
   friend WinTrace ;
   friend WinWatch ;
   friend TraceNodeEx ;
private:
   static DWORD              m_ClockSequenceBase ;
   static WORD               m_DeviceId1 ;
   static WORD               m_DeviceId2 ;
   static WORD               m_DeviceId3 ;       
   static WinTrace *         m_winTrace  ;
   static WinWatch *         m_winWatch ;
   static TraceOptions *     m_options ;
   static bool               m_IsSocketInitialized  ;
   static struct sockaddr_in m_serverSockAddr;    // Socket adress
   static int                m_socketHandle ;
   static CRITICAL_SECTION   criticalSection ;
   
   TTrace(void) {} ;   // private constructor. No instance allowed
   static void SendToClient(CommandList * Commands, const WinWatch * winWatch);   // send the trace to the viewer
   static void SendToClient(CommandList * Commands, const WinTrace * winTrace);   // send the trace to the viewer
   static void SendToClient(CommandList * Commands) ;                             // send the trace to the viewer
 
public:
   static void CloseSocket() ;                    // close viewer connection
   static char * CreateTraceID ();                // Creates unique GUID. 
   static char * WideToMbs (const wchar_t * WideStr) ;  // helper function
   
   // helper functions
   static TraceNode    * Debug()       { return m_winTrace->debug ;};
   static TraceNode    * Warning()     { return m_winTrace->warning ;} ;
   static TraceNode    * Error()       { return m_winTrace->error ;} ;
   static TraceOptions * Options()     { return m_options ; } ;  
   static WinTrace     * WindowTrace() { return m_winTrace ; } ;    
   static WinWatch     * Watches()     { return m_winWatch ; } ;
   
   
   static void ClearAll ()  ;              // clear the main trace win
   static void Show (bool IsVisible) ;     // display the viewer
   
   // TODO : Thread Sub System
   // TODO : static void Flush (FlushTimeOut : integer = 5000);
   static void Stop () ; // Stop tracetool sub system. Must be called before exiting plugin
   // TODO : static void Start() ; // restart tracetool sub system if STOP was called
   
   static DWORD Init() ;
   
}  ;

//====================================================================================

/// <summary>
/// Classic Trace Node : allow you to send simple traces.
/// Use TraceNodeEx for more complex traces.
/// The 'Send' functions don't return any object.
/// </summary>

class TraceNode 
{
   friend TraceNodeEx ;
   friend WinTrace ;
public:
   char *     id ;                           // Node id
   bool       enabled ;                      // enable or disable traces
   WinTrace * winTrace ;                     // Owner
   int        tag ;                          // User defined tag, NOT SEND to the viewer   

   TraceNode(const TraceNode * parentNode = NULL , const bool generateUniqueId = true);   // construct a new trace node, derived from a parent node 
   TraceNode(const TraceNode * parentNode , const char    * newNodeId );            // construct a new trace node, derived from a parent node 
   TraceNode(const TraceNode * parentNode , const wchar_t * newNodeId );            // construct a new trace node, derived from a parent node 

   virtual ~TraceNode(void) ;                                   // destructor

   TraceNodeEx * CreateChildEx (const char    *leftMsg = NULL, const char    *rightMsg = NULL) ;   // prepare minimal sub node without sending it 
   TraceNodeEx * CreateChildEx (const wchar_t *leftMsg = NULL, const wchar_t *rightMsg = NULL) ;   // prepare minimal sub node without sending it 
   void Indent   (const char    *leftMsg, const char    *rightMsg  = NULL) ;                       // send a node based on this node then change the indentation
   void Indent   (const wchar_t *leftMsg, const wchar_t *rightMsg  = NULL) ;                       // send a node based on this node then change the indentation
   void UnIndent (const char    *leftMsg = NULL, const char *rightMsg  = NULL) ;                   // decrement indentation
   void UnIndent (const wchar_t *leftMsg = NULL, const wchar_t *rightMsg  = NULL) ;                // decrement indentation
   int  GetIconIndex (void) ;

   void Send (const char     *leftMsg, const char     *rightMsg = NULL) ;                  // The most usefull function in that library
   void Send (const wchar_t *wLeftMsg, const wchar_t *wRightMsg = NULL) ;   
   
   void SendDump (const char    *leftMsg, const char    *rightMsg, const char    * title, const char * memory, const unsigned byteCount) ;  // send a dump to the viewer
   void SendDump (const wchar_t *leftMsg, const wchar_t *rightMsg, const wchar_t * title, const char * memory, const unsigned byteCount) ;  // send a dump to the viewer
  //TraceNode * SetFontDetail (const int ColId, const bool Bold , const bool Italic = false , const int Color = -1 , const int Size = 0 , const char * FontName = NULL) ;

protected :
   CRITICAL_SECTION criticalSection ;                                          // protect Indent and UnIndent functions
   int iconIndex ;                                                             // icon index
   deque <NodeContext *> * contextList ;                                       // context list
   const char * GetLastContextId() ;                                           // get the last context for the current thread
   void PushContextId (const char * contextId) ;                               // save the current context 
   void deleteLastContext (void) ;                                             // delete the last context for the current thread
};

//====================================================================================

/// <summary>
/// TraceNodeEx allow you to construct trace node, adding 'members' before seding it.
/// don't forget to free node.
/// </summary>

class TraceNodeEx : public TraceNode //Base 
{
   friend TTrace ;                         // TTrace add command and process members before sending it.
   friend TraceNode ;                      // TraceNode add command 
public:
   string rightMsg;                        // right message
   string leftMsg;                         // left message
   
   TraceNodeEx (TraceNode * parentNode = NULL , const bool generateUniqueId = true) ;     // constructor
   TraceNodeEx (TraceNode * parentNode , const char    * newNodeId ) ;                    // constructor
   TraceNodeEx (TraceNode * parentNode , const wchar_t * newNodeId ) ;                    // constructor
   virtual ~TraceNodeEx(void) ;                                                                 // and destructor                   
   
   TMemberNode * Members() ;                                                                    // members info
   
   TraceNodeEx * AddDump(const char    * Title , const char * memory  , const unsigned index , const unsigned byteCount) ;   // add dump to the members info
   TraceNodeEx * AddDump(const wchar_t * Title , const char * memory  , const unsigned index , const unsigned byteCount) ;   // add dump to the members info
   TraceNodeEx * AddFontDetail(const int ColId,  const bool Bold ,  const bool Italic = false,  const int Color = -1 , const int Size = 0 ,  const char * FontName = NULL) ; 

   void SetIconIndex (const int newInconIndex) ;
   void Send (void) ;                                                                // send the node
   void Send (const char    *leftMsg, const char    *rightMsg  = NULL) ;             // The most usefull function in that library
   void Send (const wchar_t *leftMsg, const wchar_t *rightMsg  = NULL) ;             // Wide version. Note : don't mix char * and wchar_t *

   void Resend (const char    *LeftMsg, const char    *RightMsg = NULL) ;            // resend left and right traces
   void Resend (const wchar_t *LeftMsg, const wchar_t *RightMsg = NULL) ;            // resend left and right traces
   void Append (const char    *LeftMsg, const char    *RightMsg = NULL) ;            // append left and right traces
   void Append (const wchar_t *LeftMsg, const wchar_t *RightMsg = NULL) ;            // append left and right traces
   void Show () ;                                                        // ensure the trace is visible in the viewer
   void SetSelected() ;                                                  // set the node as selected
   void Delete() ;                                                       // delete the node and all children
   void DeleteChildren() ;                                               // delete the trace children, not the node itself

   // SetIconIndex (int)
   
protected:
   
   TMemberNode * m_Members ;               // node members
   CommandList * Commands ;                // Commands to send
   deque <FontDetail *> * m_FontDetails ;       // fonts
} ;

//====================================================================================

/// <summary>
/// Determine how to send the trace : windows message or socket (for windows Ce for example)
/// </summary>

enum SendMode
{                                  
   WinMsg=1,                               // Windows message
      Socket                                  // Socket message
} ;

//====================================================================================

/// <summary>
/// TTrace options
/// </summary>

class TraceOptions
{
   friend TTrace ;                         // TTrace use the process file name
   friend TraceNodeEx ;                    // TraceNodeEx get TTrace options
protected :
   char * m_processFileName ;              // Process name
   char * socketHost;                      // socket host (name or ip)
   TraceOptions(void) ;                    // constructor
   ~TraceOptions(void) ;                   // and destructor
public : 
   
   SendMode sendMode ;                     // WinMsg or Socket
   int      socketPort ;                   // socket port 
   
   bool     SendProcessName ;                    // if true the process name is send
   bool     SendDate ;                           // if true the date is send
   const char * CheckProcessName() ;             // helper function : return the process name
   void     SetSocketHost (const char * Host) ;  // set the socket Host
   void     SetSocketHost (const wchar_t * Host); 
} ;


//====================================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -