<?xml version="1.0"?>

<!-- Select Reactor Specializations:
 *   ===============================
 *   Details all the specialization transformations necessary
 *   to specialize the Reactor framework when the target reactor
 *   is a select reactor.
 *
 *   @author Arvind S. Krishna <arvindk@dre.vanderbilt.edu>
 *   $Id: Select_Reactor_MT.spl 80826 2008-03-04 14:51:23Z wotte $
-->

<transform>

<!-- Define the module where there are multiple files -->
<module name="ace">

<!-- File where the transformations happen -->
<file name="Select_Reactor_Base.h">

<!-- Add the following lines based on a hook -->
<add>
  <hook>REACTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK</hook>
  <data>class ACE_Sig_Handler;</data>
  <data>class ACE_Sig_Action;</data>
  <data>class ACE_Sig_Set;</data>
</add>

<add>
 <hook>REACTOR_SPL_PUBLIC_METHODS_ADD_HOOK</hook>
 <data>
//--- How can we devirtualize these methods?
virtual ~ACE_Select_Reactor_Impl () {}

virtual int notify (ACE_Event_Handler *event_handler = 0,
                    ACE_Reactor_Mask mask = ACE_Event_Handler::EXCEPT_MASK,
                    ACE_Time_Value * = 0) =0;

virtual int remove_handler (ACE_Event_Handler *eh,
                            ACE_Reactor_Mask mask) =0;

virtual int register_handler (ACE_HANDLE handle,
                              ACE_Event_Handler *eh,
                              ACE_Reactor_Mask mask) =0;
  </data>
</add>

<!-- Remove what ever is present in the tag from the file -->
<remove>virtual</remove>
<remove>: public ACE_Reactor_Impl</remove>
<remove>#include "ace/Reactor_Impl.h"</remove>

<!-- Replace a with b -->
<substitute>
  <search>public ACE_Reactor_Notify</search>
  <replace>public ACE_Event_Handler</replace>
</substitute>

<!-- Replace the generic versions with the Select specialized versions -->
<substitute>
  <search>ACE_Reactor_Notify</search>
  <replace>ACE_Select_Reactor_Notify</replace>
</substitute>

<substitute>
 <search>ACE_Reactor_Impl</search>
 <replace>ACE_Select_Reactor_Impl</replace>
</substitute>

<!-- After the specialization, the following functions are still virtual -->
<substitute>
 <search>void renew</search>
 <replace>virtual void renew</replace>
</substitute>
<substitute>
 <search>int is_suspended_i</search>
 <replace>virtual int is_suspended_i</replace>
</substitute>
<substitute>
 <search>void clear_dispatch_mask</search>
 <replace>virtual void clear_dispatch_mask</replace>
</substitute>

</file>

<file name="Select_Reactor_Base.cpp">

<substitute>
 <search>ACE_Reactor_Impl</search>
 <replace>ACE_Select_Reactor_Impl</replace>
</substitute>

</file>

<file name="Select_Reactor_Base.inl">

<remove>#include "ace/Reactor.h"</remove>

</file>

<!-- Transformations to Reactor_Token_T.h -->
<file name="Reactor_Token_T.h">

<substitute>
 <search>ACE_Reactor_Impl</search>
 <replace>ACE_Select_Reactor_Impl</replace>
</substitute>

<substitute match-line="yes">
 <search>#include "ace/Reactor_Impl.h"</search>
 <replace>#include "ace/Select_Reactor_Base.h"</replace>
</substitute>

</file>

<file name="Reactor_Token_T.cpp">

<!-- Search for ACE_Reactor_Impl and replace it with
     ACE_Select_Reactor_Impl -->
<substitute>
 <search>ACE_Reactor_Impl</search>
 <replace>ACE_Select_Reactor_Impl</replace>
</substitute>

</file>

<file name="Select_Reactor_T.h">

<add>
<hook>REACTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK</hook>
<data>class ACE_Sig_Handler;</data>
<data>class ACE_Sig_Action;</data>
<data>class ACE_Sig_Set;</data>
</add>

<substitute>
 <search>ACE_Reactor_Notify</search>
 <replace>ACE_Select_Reactor_Notify</replace>
</substitute>

<remove>virtual</remove>

</file>

<file name="Select_Reactor_T.cpp">

<add>
 <hook>REACTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK</hook>
 <data>#include "ace/Countdown_Time.h"</data>
</add>

<substitute>
  <search>ACE_Reactor_Notify</search>
  <replace>ACE_Select_Reactor_Notify</replace>
</substitute>

</file>

<!-- 
<file name="Select_Reactor_T.inl">

<remove>#include "ace/Reactor.h"</remove>

</file>
-->

<file name="Reactor.h">

<add>
<hook>REACTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK</hook>
<data>#include "ace/Select_Reactor.h"</data>
</add>

<remove>class ACE_Reactor_Impl;</remove>
<remove>virtual</remove>

<substitute>
<search>ACE_Reactor_Impl</search>
<replace>ACE_Select_Reactor</replace>
</substitute>

<!-- Remove the Reactor_Timer interface include -->
<remove>: public ACE_Reactor_Timer_Interface</remove>
<remove>#include "ace/Reactor_Timer_Interface.h"</remove>

</file>

<file name="Event_Handler.h">

<!-- remove the ACE_Event_Handler forware declaration -->
<remove>class ACE_Reactor_Timer_Interface;</remove>

<!-- substitute ACE_Reactor_Timer operations with ACE_Reactor -->
<substitute>
 <search>ACE_Reactor_Timer_Interface</search>
 <replace>ACE_Reactor</replace>
</substitute>
</file>

<file name="Event_Handler.cpp">
 <substitute>
  <search>ACE_Reactor_Timer_Interface</search>
  <replace>ACE_Reactor</replace>
 </substitute>
</file>

<file name="Timer_Queue_T.cpp">

<!-- Remove the Reactor_Timer_Interface include -->
<remove>#include "ace/Reactor_Timer_Interface.h"</remove>

</file>


<file name="Reactor.cpp">

<!-- Comment the conditional includes in the file -->
<comment>
 <start-hook>REACTOR_SPL_COMMENT_INCLUDE_START_HOOK</start-hook>
 <end-hook>REACTOR_SPL_COMMENT_INCLUDE_END_HOOK</end-hook>
</comment>

<!-- Comment out conditional includes files in the Reactor's
     constructor
-->
<comment>
  <start-hook>REACTOR_SPL_CONSTRUCTOR_COMMENT_HOOK_START</start-hook>
  <end-hook>REACTOR_SPL_CONSTRUCTOR_COMMENT_HOOK_END</end-hook>
</comment>

<!-- Within the constructor now create the right Reactor -->
<add>
 <hook>REACTOR_SPL_CONSTRUCTOR_COMMENT_HOOK_END</hook>
 <data>
    ACE_NEW (impl,
             ACE_Select_Reactor);
 </data>
</add>

<substitute>
 <search>ACE_Reactor_Impl</search>
 <replace>ACE_Select_Reactor</replace>
</substitute>

</file>

<file name="Reactor.inl">

<add>
 <hook>REACTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK</hook>
 <data>
// Check if this is necessary
#include "ace/Select_Reactor.h"
 </data>
</add>

</file>

<!-- Do not build the other reactors than the Select Reactor! -->
<file name="ace.mpc">

<!-- Here is where regular expressions can come handy. Such
     a capability is not currently provided
 -->
<substitute>
  <search>TP_Reactor.h</search>
  <replace>// TP_Reactor.h </replace>
</substitute>
<substitute>
  <search>TP_Reactor.cpp</search>
  <replace>// TP_Reactor.cpp</replace>
</substitute>

<!-- Do not build the Msg_WFMO_Reactor -->
<substitute>
  <search>Msg_WFMO_Reactor.cpp</search>
  <replace>// Msg_WFMO_Reactor.cpp</replace>
</substitute>

<!-- Do not build the WFMO Reactor -->
<substitute>
  <search>WFMO_Reactor.cpp</search>
  <replace>// WFMO_Reactor.cpp</replace>
</substitute>

<!-- Do not build the Reactor Impl -->
<substitute>
  <search>Reactor_Impl.cpp</search>
  <replace>// Reactor_Impl.cpp</replace>
</substitute>
<substitute>
  <search>Reactor_Impl.h</search>
  <replace>// Reactor_Impl.h</replace>
</substitute>

<!-- Do not build the Dev Poll Reactor -->
<substitute>
  <search>Dev_Poll_Reactor.cpp</search>
  <replace>// Dev_Poll_Reactor.cpp</replace>
</substitute>

<!-- Do not build the priority Reactor -->
<substitute>
  <search>Priority_Reactor.cpp</search>
  <replace>// Priority_Reactor.cpp</replace>
</substitute>

<!-- Do not build the Reactor_Timer_Interface -->
<substitute>
 <search>Reactor_Timer_Interface.h</search>
 <replace>// Reactor_Timer_Interface.h</replace>
</substitute>
<substitute>
 <search>Reactor_Timer_Interface.cpp</search>
 <replace>// Reactor_Timer_Interface.cpp </replace>
</substitute>

</file>

</module>

<!-- transformations required in TAO to work with a select reactor -->
<module name="TAO/tao">

<!-- Changes to default_resource.h -->
<file name="default_resource.h">

<!-- Remove the forward declaration of ACE_Reactor_Impl -->
<substitute match-line="yes">
<search>class ACE_Reactor_Impl;</search>
<replace>#include "ace/Reactor.h"</replace>
</substitute>

<!-- Replace all occurences of ACE_Reactor_Impl with
     ACE_Select_Reactor -->
<substitute>
 <search>ACE_Reactor_Impl</search>
 <replace>ACE_Select_Reactor</replace>
</substitute>

</file>

<!-- Changes to default_resource.cpp -->
<file name="default_resource.cpp">

<!-- Remove the occurence of TP_Reactor -->
<remove>#include "ace/TP_Reactor.h"</remove>

<!-- Replace all occurences of ACE_Reactor_Impl with
     ACE_Select_Reactor -->
<substitute>
 <search>ACE_Reactor_Impl</search>
 <replace>ACE_Select_Reactor</replace>
</substitute>

<!-- Comment out the code that creates TP_Reactor -->
<comment>
 <start-hook>TAO_REACTOR_SPL_COMMENT_HOOK_START</start-hook>
 <end-hook>TAO_REACTOR_SPL_COMMENT_HOOK_END</end-hook>
</comment>

<!-- Add hook to add code that creates the select reactor
     component -->
<add>
 <!-- We use the same hook that signifies where the comment code
      ended to add the concrete Reactor type -->
 <hook>TAO_REACTOR_SPL_COMMENT_HOOK_END</hook>
 <data>
  ACE_NEW_RETURN (impl,
                  TAO_REACTOR ((ACE_Sig_Handler*)0,
                               (ACE_Timer_Queue*)0,
                                0,
                               (ACE_Select_Reactor_Notify*)0,
                                this->reactor_mask_signals_),
                  0);
 </data>
</add>
</file>

<!-- changes to tao.mpc -->
<file name="tao.mpc">
 <substitute>
  <search>GUIResource_Factory.cpp</search>
  <replace>// GUIResource_Factory.cpp</replace>
 </substitute>
 <substitute>
  <search>GUIResource_Factory.h</search>
  <replace>// GUIResource_Factory.h</replace>
 </substitute>
</file>

</module>

<module name="TAO/tao/Strategies">

<file name="advanced_resource.h">

<!-- Replace all occurances of ACE_Reactor_Impl with
     Select_Reactor
  -->
<substitute>
  <search>ACE_Reactor_Impl</search>
  <replace>ACE_Select_Reactor</replace>
</substitute>

</file>

<file name="advanced_resource.cpp">

<!-- Comment out all other reactor includes -->
<remove>#include "ace/FlReactor.h"</remove>
<remove>#include "ace/TkReactor.h"</remove>
<remove>#include "ace/WFMO_Reactor.h"</remove>
<remove>#include "ace/TP_Reactor.h"</remove>
<remove>#include "ace/Msg_WFMO_Reactor.h"</remove>

<substitute>
  <search>ACE_Reactor_Impl</search>
  <replace>ACE_Select_Reactor</replace>
</substitute>

<!-- Replace Select_Reactor.h with Reactor.h -->
<substitute>
 <search>ace/Select_Reactor.h</search>
 <replace>ace/Reactor.h</replace>
</substitute>

<!-- Comment out creation code for all other reactors -->
<comment>
 <start-hook>TAO_ADVANCED_RESOURCE_REACTOR_SPL_COMMENT_HOOK_START</start-hook>
 <end-hook>TAO_ADVANCED_RESOURCE_REACTOR_SPL_COMMENT_HOOK_END</end-hook>
</comment>

<!-- Use the end hook to insert code that will create right reactor -->
<add>
  <hook>TAO_ADVANCED_RESOURCE_REACTOR_SPL_COMMENT_HOOK_END</hook>
  <data>
     ACE_NEW_RETURN (impl,
                     TAO_REACTOR ((ACE_Sig_Handler*)0,
                                  (ACE_Timer_Queue*)0,
                                   0,
                                  (ACE_Select_Reactor_Notify*)0,
                                  this->reactor_mask_signals_),
                      0);
  </data>
</add>

</file>

</module>

</transform>
