Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. dbgfac.cxx
  6. Abstract:
  7. Debug Device Class Factory
  8. Author:
  9. Steve Kiraly (SteveKi) 10-Dec-1995
  10. Revision History:
  11. --*/
  12. #include "precomp.hxx"
  13. #pragma hdrstop
  14. #include "dbgfac.hxx"
  15. #include "dbgdbg.hxx"
  16. #include "dbgnul.hxx"
  17. #include "dbgcon.hxx"
  18. #include "dbgfil.hxx"
  19. #include "dbgsterm.hxx"
  20. #include "dbgback.hxx"
  21. TDebugFactory::
  22. TDebugFactory(
  23. VOID
  24. )
  25. {
  26. }
  27. TDebugFactory::
  28. ~TDebugFactory(
  29. VOID
  30. )
  31. {
  32. }
  33. BOOL
  34. TDebugFactory::
  35. bValid(
  36. VOID
  37. ) const
  38. {
  39. return TRUE;
  40. }
  41. TDebugDevice *
  42. TDebugFactory::
  43. Produce(
  44. IN UINT uDevice,
  45. IN LPCTSTR pszConfiguration,
  46. IN BOOL bUnicode
  47. )
  48. {
  49. LPTSTR pszCharacterType = NULL;
  50. TDebugDevice *pDebugDevice = NULL;
  51. TDebugString strConfig;
  52. //
  53. // Ensure the configuration string points to something valid.
  54. //
  55. if( !pszConfiguration )
  56. {
  57. pszConfiguration = const_cast<LPTSTR>( kstrNull );
  58. }
  59. //
  60. // Prefix the configuration string with the character type
  61. // directive. The configuration string is a string of device
  62. // specific commands separated by colans.
  63. //
  64. pszCharacterType = bUnicode ? const_cast<LPTSTR>( kstrUnicode )
  65. : const_cast<LPTSTR>( kstrAnsi );
  66. //
  67. // Update the configuration string.
  68. //
  69. if( strConfig.bUpdate( pszCharacterType ) &&
  70. strConfig.bCat( kstrSeparator ) &&
  71. strConfig.bCat( pszConfiguration ) )
  72. {
  73. //
  74. // Instantiate the debug device.
  75. //
  76. switch( uDevice )
  77. {
  78. case kDbgConsole: // Text console
  79. pDebugDevice = INTERNAL_NEW TDebugDeviceConsole( strConfig, kDbgConsole );
  80. break;
  81. case kDbgDebugger: // Debug console
  82. pDebugDevice = INTERNAL_NEW TDebugDeviceDebugger( strConfig, kDbgDebugger );
  83. break;
  84. case kDbgNull: // Null Device to nothing
  85. pDebugDevice = INTERNAL_NEW TDebugDeviceNull( strConfig, kDbgNull );
  86. break;
  87. case kDbgFile: // Log file
  88. pDebugDevice = INTERNAL_NEW TDebugDeviceFile( strConfig, kDbgFile );
  89. break;
  90. case kDbgSerialTerminal: // Serial Terminal
  91. pDebugDevice = INTERNAL_NEW TDebugDeviceSerialTerminal( strConfig, kDbgSerialTerminal );
  92. break;
  93. case kDbgBackTrace: // Backtrace
  94. pDebugDevice = INTERNAL_NEW TDebugDeviceBacktrace( strConfig, kDbgBackTrace );
  95. break;
  96. default:
  97. pDebugDevice = NULL;
  98. break;
  99. }
  100. }
  101. //
  102. // If not valid release the debug device.
  103. //
  104. if( !pDebugDevice || !pDebugDevice->bValid() )
  105. {
  106. INTERNAL_DELETE pDebugDevice;
  107. pDebugDevice = NULL;
  108. }
  109. //
  110. // Return product pointer.
  111. //
  112. return pDebugDevice;
  113. }
  114. //
  115. // Dispose of the product.
  116. //
  117. VOID
  118. TDebugFactory::
  119. Dispose(
  120. IN TDebugDevice *pDevice
  121. )
  122. {
  123. INTERNAL_DELETE pDevice;
  124. }