/* 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.
 *
 */

#ifndef NMM_OUT_OF_BAND_COMPOSITE_ADDRESS_HPP
#define NMM_OUT_OF_BAND_COMPOSITE_ADDRESS_HPP NMM_OUT_OF_BAND_COMPOSITE_ADDRESS_HPP

#include "nmm/nmm_prefix.hpp"

#include "CompositeAddress.hpp"

#include "visibility.hpp"

namespace NMM {
  
  /** A composite address for an out-of-band binding.
   *
   * This address is a %CompositeAddress which is build of one or more child addresses. In addition to this,
   * it allows assigning child addresses to the specific roles of an out-of-band binding.
   * @see OutOfBandCompositeStrategy
   */
  class DLLEXPORT OutOfBandCompositeAddress
    : public CompositeAddress
  {
  public:
    /** @name Constructor & Destructor
     */
    //@{
    /** Constructs an %OutofBandCompositeAddress with no child addresses.
     *
     * @param ref NMM reference
     */
    OutOfBandCompositeAddress(const NMMReference& ref = 0) throw();
    
    /** Copy constructor.
     *
     * @param obca OutOfBandCompositeAddress to be copied
     */
    OutOfBandCompositeAddress(const OutOfBandCompositeAddress& obca) throw();
    
    /** Virtual copy constructor.
     *
     * @return pointer to copy of this OutOufBandCompositeAddress
     */
    virtual OutOfBandCompositeAddress* copy() const throw();
    //@}
    
    /** @name Roles
     */
    //@{
    /** Sets the address to use for receiving one-way %Event requests.
     *
     * This method assigns an address to a communication role. Exactly one address must be assigned to each role.
     *
     * @param address_index Index of child address to assign to this role
     */
    inline void setOneWayEventRequestReceiverAddress(int address_index) throw() {
      __one_way_event_request_receiver_address.setValue(address_index);
    }
    
    /** Sets the address to use for receiving one-way %Event replies.
     *
     * This method assigns an address to a communication role. Exactly one address must be assigned to each role.
     *
     * @param address_index Index of child address to assign to this role
     */
    inline void setOneWayEventReplyReceiverAddress(int address_index) throw() {
      __one_way_event_reply_receiver_address.setValue(address_index);
    }
    
    /** Sets the address to use for sending one-way %Event requests.
     *
     * This method assigns an address to a communication role. Exactly one address must be assigned to each role.
     *
     * @param address_index Index of child address to assign to this role
     */
    inline void setOneWayEventRequestSenderAddress(int address_index) throw() {
      __one_way_event_request_sender_address.setValue(address_index);
    }
    
    /** Sets the address to use for sending one-way %Event replies.
     *
     * This method assigns an address to a communication role. Exactly one address must be assigned to each role.
     *
     * @param address_index Index of child address to assign to this role
     */
    inline void setOneWayEventReplySenderAddress(int address_index) throw() {
      __one_way_event_reply_sender_address.setValue(address_index);
    }
    
    /** Sets the address to use for receiving request-reply Events.
     *
     * This method assigns an address to a communication role. Exactly one address must be assigned to each role.
     *
     * @param address_index Index of child address to assign to this role
     */
    inline void setRequestReplyEventReceiverAddress(int address_index) throw() {
      __request_reply_event_receiver_address.setValue(address_index);
    }

    /** Sets the address to use for sending request-reply Events.
     *
     * This method assigns an address to a communication role. Exactly one address must be assigned to each role.
     *
     * @param address_index Index of child address to assign to this role
     */
    inline void setRequestReplyEventSenderAddress(int address_index) throw() {
      __request_reply_event_sender_address.setValue(address_index);
    }
    
    /** Returns the address to use for receiving one-way %Event requests.
     *
     * This method returns the address assigned to a communication role.
     *
     * @return Index of child address to assign to this role
     */
    inline int getOneWayEventRequestReceiverAddress() const throw() {
      return __one_way_event_request_receiver_address.getRValue();
    }
    
    /** Returns the address to use for receiving one-way %Event replies.
     *
     * This method returns the address assigned to a communication role.
     *
     * @return Index of child address to assign to this role
     */
    inline int getOneWayEventReplyReceiverAddress() const throw() {
      return __one_way_event_reply_receiver_address.getRValue();
    }
    
    /** Returns the address to use for sending one-way %Event requests.
     *
     * This method returns the address assigned to a communication role.
     *
     * @return Index of child address to assign to this role
     */
    inline int getOneWayEventRequestSenderAddress() const throw() {
      return __one_way_event_request_sender_address.getRValue();
    }
    
    /** Returns the address to use for sending one-way %Event replies.
     *
     * This method returns the address assigned to a communication role.
     *
     * @return Index of child address to assign to this role
     */
    inline int getOneWayEventReplySenderAddress() const throw() {
      return __one_way_event_reply_sender_address.getRValue();
    }

    /** Returns the address to use for receiving request-reply Events.
     *
     * This method returns the address assigned to a communication role.
     *
     * @return Index of child address to assign to this role
     */
    inline int getRequestReplyEventReceiverAddress() const throw() {
      return __request_reply_event_receiver_address.getRValue();
    }

    /** Returns the address to use for sending request-reply Events.
     *
     * This method returns the address assigned to a communication role.
     *
     * @return Index of child address to assign to this role
     */
    inline int getRequestReplyEventSenderAddress() const throw() {
      return __request_reply_event_sender_address.getRValue();
    }
    
    /** Tests if this composite address is complete.
     *
     * A composite address is complete if all communication roles have been assigned an address.
     *
     * @return @c true, if this address is complete, otherwise @c false
     */
    virtual bool isComplete() const throw();
    //@}
    
  private:
    /** Registers all attributes for serialization.
     */
    void registerAttributes() throw();
    
  private:
    TValue<nmm_int32> __one_way_event_request_receiver_address;     ///< Address assigned to role for receiving one-way %Event requests.
    TValue<nmm_int32> __one_way_event_reply_receiver_address;       ///< Address assigned to role for receiving one-way %Event replies.
    TValue<nmm_int32> __one_way_event_request_sender_address;       ///< Address assigned to role for sending one-way %Event requests.
    TValue<nmm_int32> __one_way_event_reply_sender_address;         ///< Address assigned to role for sending one-way %Event replies.
    TValue<nmm_int32> __request_reply_event_receiver_address;       ///< Address assigned to role for receiving request-reply Events.
    TValue<nmm_int32> __request_reply_event_sender_address;         ///< Address assigned to role for sending request-reply Events.
  };
  
}

#include "nmm/nmm_suffix.hpp"

#endif
