/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *  
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *  
 * This file is part of NMM. 
 * 
 * NMM is free software; you can redistribute it and/or modify it    
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; only version 2 of the License.      
 * 
 * NMM is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 
 * License for more details.  
 * 
 * You should have received a copy of the GNU General Public License 
 * along with NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

/** @file StaticTransportStrategyList.hpp
 *
 * This file must be included to guarantee linking of static
 * constructors of transport strategies when --enable-static is set.
 */

#ifndef NMM_STATIC_TRANSPORT_STRATEGY_LIST_HPP
#define NMM_STATIC_TRANSPORT_STRATEGY_LIST_HPP NMM_STATIC_TRANSPORT_STRATEGY_LIST_HPP

#include "nmm/nmm_prefix.hpp"

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "nmm/comm/TTSFactoryRegistrator.hpp"
#include "nmm/comm/TTSFactoryObject.hpp"

#ifdef BUILD_TCP
#include "TCPStrategy.hpp"
#endif
#ifdef BUILD_UDP
#include "UDPStrategy.hpp"
#endif
#ifdef BUILD_RTP
#include "RTPSenderStrategy.hpp"
#include "RTPReceiverStrategy.hpp"
#endif

#ifdef ENABLE_STATIC

namespace NMM {
  
#ifdef BUILD_TCP
  /** Static constructor for TCPStrategy.
   * This static constructor registers the TCPStrategy at the TSFactory.
   */
  extern TTSFactoryRegistrator< TTSFactoryObject<TCPStrategy> >
  __tcp_strategy_prototype;
#endif
  
#ifdef BUILD_UDP
  /** Static constructor for UDPStrategy.
   * This static constructor registers the TCPStrategy at the TSFactory.
   */
  extern TTSFactoryRegistrator< TTSFactoryObject<UDPStrategy> >
  __udp_strategy_prototype;  
#endif
  
#ifdef BUILD_RTP
  /** Static constructor for RTPSenderStrategy.
   * This static constructor registers the RTPSenderStrategy at the TSFactory.
   */
  extern TTSFactoryRegistrator< TTSFactoryObject<RTPSenderStrategy> >
  __rtp_send_strategy_prototype;

  /** Static constructor for RTPReceiverStrategy.
   * This static constructor registers the RTPReceiverStrategy at the TSFactory.
   */
  extern TTSFactoryRegistrator< TTSFactoryObject<RTPReceiverStrategy> >
  __rtp_recv_strategy_prototype;  
#endif

  static TSFactoryRegistrator* __static_strategy_list[] = {
#ifdef BUILD_TCP
    &__tcp_strategy_prototype,
#endif
#ifdef BUILD_UDP
    &__udp_strategy_prototype,
#endif
#ifdef BUILD_RTP
    &__rtp_send_strategy_prototype,
    &__rtp_recv_strategy_prototype,
#endif
    0
  };
  
  // XXX: fw: pretend that the above list is used (prevent warning and make sure it is linked)
  // XXX: fw: doesn't work, causes segfault because of order of static object instantiation.
//   static class DummyStrategyList {
//   public:
//     DummyStrategyList() {
//       for(TSFactoryRegistrator** ptr = __static_strategy_list;
//           *ptr != 0;
//           ++ptr) {
//         (*ptr)->dummy();
//       }
//     }
//   } __dummy_strategy_list;
  
}

#endif

#include "nmm/nmm_suffix.hpp"

#endif
