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

  1. //-----------------------------------------------------------------------------
  2. // Visual Database Tools
  3. // Copyright (c) 1996 by Borland International, All Rights Reserved
  4. //
  5. // batch.cpp
  6. // TBatchMove wrapper class
  7. //-----------------------------------------------------------------------------
  8.  
  9. #include <vdbt\bdto.h>
  10.  
  11. #pragma hdrstop
  12.  
  13. #include "wrapit.h"
  14. #include "misc.h"
  15.  
  16. //-----------------------------------------------------------------------------
  17.  
  18. void TBatchMove::SetTBatchMove( PIUnknown p )
  19. {
  20.     batchmove = 0;
  21.     if (p)
  22.         p->QueryInterface( IID_ITBatchMove, (void**) &batchmove );
  23. }
  24.  
  25. void TBatchMove::ClearTBatchMove( void )
  26. {
  27.     if (batchmove)
  28.     {
  29.         batchmove->Release();
  30.         batchmove = 0;
  31.     }
  32. }
  33.  
  34. TBatchMove::TBatchMove( void ) : TBDTComponent()
  35. {
  36.     batchmove = CreateITBatchMove();
  37.     TBDTComponent::SetPIT( batchmove );
  38. }
  39.  
  40. TBatchMove::TBatchMove( PITBatchMove p ) : TBDTComponent( p )
  41. {
  42.     SetTBatchMove( p );
  43. }
  44.  
  45. TBatchMove::TBatchMove( const TBatchMove& p ) : TBDTComponent( p )
  46. {
  47.     SetTBatchMove( p.batchmove );
  48. }
  49.  
  50. TBatchMove::TBatchMove( PTBatchMove p ) : TBDTComponent( p )
  51. {
  52.     SetTBatchMove( p ? p->batchmove : 0 );
  53. }
  54.  
  55. TBatchMove::TBatchMove( HWND hdlg, int idc ) : TBDTComponent()
  56. {
  57.     SetTBatchMove( GetVBXPIUnknown( hdlg, idc ) );
  58.     TBDTComponent::SetPIT( batchmove );
  59. }
  60.  
  61. void TBatchMove::AttachToControl( HWND hdlg, int idc )
  62. {
  63.     SetPIT( GetVBXPIUnknown( hdlg, idc ) );
  64. }
  65.  
  66. void TBatchMove::AttachControl( HWND hdlg, int idc )
  67. {
  68.     SetVBXPIUnknown( hdlg, idc, batchmove );
  69. }
  70.  
  71. TBatchMove& TBatchMove::operator=( PITBatchMove p )
  72. {
  73.     TBDTComponent::operator=(p);
  74.     ClearTBatchMove();
  75.     SetTBatchMove( p );
  76.     return *this;
  77. }
  78.  
  79. TBatchMove& TBatchMove::operator=( const TBatchMove& p )
  80. {
  81.     if (this != &p)
  82.     {
  83.         TBDTComponent::operator=(p);
  84.         ClearTBatchMove();
  85.         SetTBatchMove( p.batchmove );
  86.     }
  87.     return *this;
  88. }
  89.  
  90. int TBatchMove::operator==( const TBatchMove& p ) const
  91. {
  92.     if (this == &p)
  93.         return true;
  94.     if (batchmove == p.batchmove)
  95.         return true;
  96.     return false;
  97. }
  98.  
  99. int TBatchMove::operator!=( const TBatchMove& p ) const
  100. {
  101.     return ! operator==(p);
  102. }
  103.  
  104. TBatchMove::~TBatchMove()
  105. {
  106.     ClearTBatchMove();
  107. }
  108.  
  109. void TBatchMove::SetPIT( PIUnknown p )
  110. {
  111.     ClearTBatchMove();
  112.     SetTBatchMove( p );
  113.     TBDTComponent::SetPIT( p );
  114. }
  115.  
  116. void TBatchMove::Execute( void )
  117. {
  118.     if (batchmove)
  119.         batchmove->Execute();
  120. }
  121.  
  122. DEFINE_BDTO_PROP_RO( TBatchMove, int32, ChangedCount );
  123. DEFINE_BDTO_PROP_RO( TBatchMove, int32, KeyViolCount );
  124. DEFINE_BDTO_PROP_RO( TBatchMove, int32, MovedCount );
  125. DEFINE_BDTO_PROP_RO( TBatchMove, int32, ProblemCount );
  126.  
  127. void TBatchMove::GetChangedCount( int32& c )
  128. {
  129.     if (batchmove)
  130.         c = batchmove->get_ChangedCount();
  131. }
  132.  
  133. void TBatchMove::GetKeyViolCount( int32& c )
  134. {
  135.     if (batchmove)
  136.         c = batchmove->get_KeyViolCount();
  137. }
  138.  
  139. void TBatchMove::GetMovedCount( int32& c )
  140. {
  141.     if (batchmove)
  142.         c = batchmove->get_MovedCount();
  143. }
  144.  
  145. void TBatchMove::GetProblemCount( int32& c )
  146. {
  147.     if (batchmove)
  148.         c = batchmove->get_ProblemCount();
  149. }
  150.  
  151. DEFINE_BDTO_PROP_RW( TBatchMove, bool, AbortOnKeyViol );
  152. DEFINE_BDTO_PROP_RW( TBatchMove, bool, AbortOnProblem );
  153. DEFINE_BDTO_OBJECTPROP_RW( TBatchMove, string, ChangedTableName );
  154. DEFINE_BDTO_OBJECTPROP_RW_FAST( TBatchMove, TTable, PITTable, Destination );
  155. DEFINE_BDTO_OBJECTPROP_RW( TBatchMove, string, KeyViolTableName );
  156. DEFINE_BDTO_OBJECTPROP_RW_FAST( TBatchMove, TStrings, PITStrings, Mappings );
  157. DEFINE_BDTO_PROP_RW( TBatchMove, TBatchMode, Mode );
  158. DEFINE_BDTO_OBJECTPROP_RW( TBatchMove, string, ProblemTableName );
  159. DEFINE_BDTO_PROP_RW( TBatchMove, int32, RecordCount );
  160. DEFINE_BDTO_OBJECTPROP_RW_FAST( TBatchMove, TDataSet, PITDataSet, Source );
  161. DEFINE_BDTO_PROP_RW( TBatchMove, bool, Transliterate );
  162.  
  163. void TBatchMove::GetAbortOnKeyViol( bool& a )
  164. {
  165.     if (batchmove)
  166.         a = MakeBool( batchmove->get_AbortOnKeyViol() );
  167. }
  168.  
  169. void TBatchMove::SetAbortOnKeyViol( bool a )
  170. {
  171.     if (batchmove)
  172.         batchmove->put_AbortOnKeyViol( MakeVariantBool( a ) );
  173. }
  174.  
  175. void TBatchMove::GetAbortOnProblem( bool& a )
  176. {
  177.     if (batchmove)
  178.         a = MakeBool( batchmove->get_AbortOnProblem() );
  179. }
  180.  
  181. void TBatchMove::SetAbortOnProblem( bool a )
  182. {
  183.     if (batchmove)
  184.         batchmove->put_AbortOnProblem( MakeVariantBool( a ) );
  185. }
  186.  
  187. void TBatchMove::GetChangedTableName( string& s )
  188. {
  189.     if (batchmove)
  190.         AnyString( batchmove->get_ChangedTableName() ).GetString( s );
  191. }
  192.  
  193. void TBatchMove::SetChangedTableName( const string& n )
  194. {
  195.     if (batchmove)
  196.         batchmove->put_ChangedTableName( AnyString(n).GetPITAnyString() );
  197. }
  198.  
  199. void TBatchMove::GetDestination( TTable& t )
  200. {
  201.     if (batchmove)
  202.     {
  203.         PITTable pit = batchmove->get_Destination();
  204.         if (pit)
  205.         {
  206.             t.SetPIT( pit );
  207.             pit->Release();
  208.         }
  209.     }
  210. }
  211.  
  212. void TBatchMove::SetDestination( const TTable& t )
  213. {
  214.     if (batchmove)
  215.         batchmove->put_Destination( t.GetPITTable() );
  216. }
  217.  
  218. void TBatchMove::GetKeyViolTableName( string& s )
  219. {
  220.     if (batchmove)
  221.         AnyString( batchmove->get_KeyViolTableName() ).GetString( s );
  222. }
  223.  
  224. void TBatchMove::SetKeyViolTableName( const string& n )
  225. {
  226.     if (batchmove)
  227.         batchmove->put_KeyViolTableName( AnyString(n).GetPITAnyString() );
  228. }
  229.  
  230. void TBatchMove::GetMappings( TStrings& s )
  231. {
  232.     if (batchmove)
  233.     {
  234.         PITStrings pit = batchmove->get_Mappings();
  235.         if (pit)
  236.         {
  237.             s.SetPIT( pit );
  238.             pit->Release();
  239.         }
  240.     }
  241. }
  242.  
  243. void TBatchMove::SetMappings( const TStrings& s )
  244. {
  245.     if (batchmove)
  246.         batchmove->put_Mappings( s.GetPITStrings() );
  247. }
  248.  
  249. void TBatchMove::GetMode( TBatchMode& m )
  250. {
  251.     if (batchmove)
  252.         m = batchmove->get_Mode();
  253. }
  254.  
  255. void TBatchMove::SetMode( TBatchMode m )
  256. {
  257.     if (batchmove)
  258.         batchmove->put_Mode( m );
  259. }
  260.  
  261. void TBatchMove::GetProblemTableName( string& s )
  262. {
  263.     if (batchmove)
  264.         AnyString( batchmove->get_ProblemTableName() ).GetString( s );
  265. }
  266.  
  267. void TBatchMove::SetProblemTableName( const string& n )
  268. {
  269.     if (batchmove)
  270.         batchmove->put_ProblemTableName( AnyString(n).GetPITAnyString() );
  271. }
  272.  
  273. void TBatchMove::GetRecordCount( int32& c )
  274. {
  275.     if (batchmove)
  276.         c = batchmove->get_RecordCount();
  277. }
  278.  
  279. void TBatchMove::SetRecordCount( int32 c )
  280. {
  281.     if (batchmove)
  282.         batchmove->put_RecordCount( c );
  283. }
  284.  
  285. void TBatchMove::GetSource( TDataSet& d )
  286. {
  287.     if (batchmove)
  288.     {
  289.         PITDataSet pit = batchmove->get_Source();
  290.         if (pit)
  291.         {
  292.             d.SetPIT( pit );
  293.             pit->Release();
  294.         }
  295.     }
  296. }
  297.  
  298. void TBatchMove::SetSource( const TDataSet& d )
  299. {
  300.     if (batchmove)
  301.         batchmove->put_Source( d.GetPITDataSet() );
  302. }
  303.  
  304. void TBatchMove::GetTransliterate( bool& t )
  305. {
  306.     if (batchmove)
  307.         t = MakeBool( batchmove->get_Transliterate() );
  308. }
  309.  
  310. void TBatchMove::SetTransliterate( bool t )
  311. {
  312.     if (batchmove)
  313.         batchmove->put_Transliterate( MakeVariantBool( t ) );
  314. }
  315.  
  316.