home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / ADDON.PAK / TARGET.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  4.3 KB  |  139 lines

  1. /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2.  
  3.   target.cpp
  4.   Created: 10/26/95
  5.   Copyright (c) 1995, Borland International
  6.   $Revision:   1.18  $
  7.    
  8. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/  
  9. #ifndef __AOEXPCH_H
  10.   #include "aoexpch.h"
  11. #endif
  12. #pragma hdrstop
  13.  
  14. #include <ideaddon\iproj.h>
  15. #include <ideaddon\iide.h>
  16. #include "target.h"
  17. #include "txowl.h"
  18. //.............................................................................
  19. TargetTestA::TargetTestA() { 
  20.   d_owlTarget = 0;
  21.   _targetServer = NULL; 
  22. }
  23. //.............................................................................
  24. TargetTestA::~TargetTestA() {
  25.   UnInit();
  26. }
  27.  
  28. //.............................................................................
  29. BOOL TargetTestA::Init() {
  30.   OutStr( "TargetTestA::Init()" );
  31.   if ( !_targetServer ) {
  32.     _targetServer = GET_INTERFACE( ITargetServer );
  33.   }
  34.   return _targetServer? TRUE : FALSE;
  35. }
  36. //.............................................................................
  37. void TargetTestA::UnInit() {
  38.   OutStr( "TargetTestA::UnInit()" );
  39.   if ( _targetServer ) {
  40.     _targetServer->Release();
  41.     _targetServer = NULL;
  42.   }
  43.   if ( d_owlTarget ) {
  44.    d_owlTarget->Release();
  45.   }
  46. }  
  47. //.............................................................................
  48. const char * TargetTestA::GetName() {
  49.   return "TargetServer Test A";
  50. }
  51. //.............................................................................
  52. const char * TargetTestA::GetTestDescription( int testNum ) {
  53.   switch ( testNum ) {
  54.     case 1: 
  55.       return "Adds various targets to the current project.";
  56.     case 2: 
  57.       return "Adding custom target Win32 OWL application.";
  58.     case 3:
  59.       return "Is current node a target?";
  60.   }
  61.   return "This test not implemented.";
  62. }  
  63.  
  64. struct Target {
  65.   const char * nodeName;
  66.   TargetType type;
  67.   TargetPlatform platform;
  68.   int libs;
  69.   TargetModel model;
  70. };
  71. static Target targets[] = {
  72.   { "Exe-Win32-StdLibsDyn-Gui", TT_Application, TP_Win32, TL_StdLibs|TL_Dynamic, TM_Gui },
  73.   { "Exe-Win32-StdLibsDyn-Console", TT_Application, TP_Win32, TL_Bids|TL_Rtl|TL_Dynamic, TM_FsConsole },
  74.   { "Dll-Win32-StdLibsDyn-Gui", TT_Dll, TP_Win32, TL_StdLibs|TL_Dynamic, TM_Gui },
  75.   { "Dll-Win16-StdLibsDyn-Gui", TT_Dll, TP_Win16, TL_StdLibs|TL_Dynamic, TM_Gui },
  76.   { "Exe-DosOverlay-Large", TT_Application, TP_DosOverlay, TL_StdLibs|TL_Dynamic, TM_Large },
  77.   { "Exe-Dos16-StdLibsStatic-Small", TT_Application, TP_Dos16, TL_StdLibs|TL_Static, TM_Small },
  78.   { "Lib-Dos16-STdLibs-Medium", TT_StaticLib, TP_Dos16, TL_StdLibs, TM_Medium },
  79.   { NULL }
  80. };  
  81. //.............................................................................
  82. void TargetTestA::DoTest( int testNum ) {
  83.   if ( !_targetServer ) {
  84.     OutStr( "TargetServer not initialized!" );
  85.     return;
  86.   }
  87.   switch ( testNum ) {
  88.     case 1: {
  89.       Target * t = targets;
  90.       while ( t->nodeName ) {
  91.         ProjectNode node = _targetServer->TargetAdd(
  92.               MakePolyString( t->nodeName ),
  93.               0,
  94.               t->type,
  95.               t->platform,
  96.               t->libs,
  97.               t->model );
  98.         if ( _targetServer->NodeIsTarget( node ) ) {
  99.           OutStr( FormatStr( "New target %s added.", t->nodeName ) );
  100.         }
  101.         else {
  102.           OutStr( FormatStr( "Problem creating target: %s.", t->nodeName ) );
  103.         }
  104.               
  105.         ++t;
  106.       }
  107.       break;
  108.     }
  109.     case 2: {
  110.       OutStr( "Adding custom target Win32 OWL application." );
  111.       d_owlTarget = (ITargetType*)new OwlTargetImpl(GetIdeServer());
  112.       break;
  113.     }
  114.     case 3: {
  115.       IProjectServer * projectServer = GET_INTERFACE( IProjectServer );
  116.       if ( projectServer ) {
  117.         int numNodes;
  118.         ProjectNode * nodes = projectServer->QuerySelectedNodes( &numNodes );
  119.         if ( numNodes ) {
  120.           OutStr( FormatStr( "Selected node is %s target.", 
  121.               _targetServer->NodeIsTarget( nodes[0] )? "a" : "not a" ) );
  122.         }
  123.         else {
  124.           OutStr( "No node selected." );
  125.         }
  126.         projectServer->Release();
  127.       }
  128.       break;
  129.     }
  130.     default: {
  131.       OutStr( FormatStr( "Test #%d Not Implemented!", testNum ) );
  132.     }
  133.   }
  134. }
  135.  
  136.  
  137.  
  138. 
  139.