text: //----------------------------------------------------------------------------
  //
  // TSDuck - The MPEG Transport Stream Toolkit
  // Copyright (c) 2005-2021, Thierry Lelegard
  // All rights reserved.
  //
  // Redistribution and use in source and binary forms, with or without
  // modification, are permitted provided that the following conditions are met:
  //
  // 1. Redistributions of source code must retain the above copyright notice,
  //    this list of conditions and the following disclaimer.
  // 2. Redistributions in binary form must reproduce the above copyright
  //    notice, this list of conditions and the following disclaimer in the
  //    documentation and/or other materials provided with the distribution.
  //
  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  // THE POSSIBILITY OF SUCH DAMAGE.
  //
  //----------------------------------------------------------------------------
  //!
  //!  @file
  //!  Input switch (tsswitch) plugin executor thread.
  //!
  //----------------------------------------------------------------------------
  
  #pragma once
  #include "tsPluginThread.h"
  #include "tsInputSwitcherArgs.h"
  #include "tsPluginEventHandlerRegistry.h"
  
  namespace ts {
      namespace tsswitch {
  
          class Core;
  
          //!
          //! Execution context of a tsswitch plugin.
          //! @ingroup plugin
          //!
          class PluginExecutor : public PluginThread
          {
              TS_NOBUILD_NOCOPY(PluginExecutor);
          public:
              //!
              //! Constructor.
              //! @param [in] opt Command line options.
              //! @param [in] handlers Registry of event handlers.
              //! @param [in] type Plugin type.
              //! @param [in] pl_options Command line options for this plugin.
              //! @param [in] attributes Creation attributes for the thread executing this plugin.
              //! @param [in,out] core Command core instance.
              //! @param [in,out] log Log report.
              //!
              PluginExecutor(const InputSwitcherArgs& opt,
                             const PluginEventHandlerRegistry& handlers,
                             PluginType type,
                             const PluginOptions& pl_options,
                             const ThreadAttributes& attributes,
                             Core& core,
                             Report& log);
  
              //!
              //! Destructor.
              //!
              virtual ~PluginExecutor() override;
  
              // Implementation of TSP. We do not use "joint termination" in tsswitch.
              virtual void useJointTermination(bool) override;
              virtual void jointTerminate() override;
              virtual bool useJointTermination() const override;
              virtual bool thisJointTerminated() const override;
              virtual size_t pluginCount() const override;
              virtual void signalPluginEvent(uint32_t event_code, Object* plugin_data = nullptr) const override;
  
          protected:
              const InputSwitcherArgs& _opt;   //!< Command line options.
              Core&                    _core;  //!< Application core.
  
          private:
              const PluginEventHandlerRegistry& _handlers;  //!< Registry of event handlers.
          };
      }
  }
  