/* 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_INSTREAM_COMPOSITE_ADDRESS_HPP
#define NMM_INSTREAM_COMPOSITE_ADDRESS_HPP NMM_INSTREAM_COMPOSITE_ADDRESS_HPP

#include "nmm/nmm_prefix.hpp"

#include "CompositeAddress.hpp"

#include "visibility.hpp"

namespace NMM {
  
  /** A composite address for an instream 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 instream binding.
   * @see InstreamCompositeStrategy
   */
  class DLLEXPORT InstreamCompositeAddress
    : public CompositeAddress
  {
  public:
    /** @name Constructor & Destructor
     */
    //@{
    /** Construct an %InstreamCompositeAddress with no child addresses.
     * @param ref NMM reference
     */
    InstreamCompositeAddress(const NMMReference& ref = 0) throw();
    
    /** Copy constructor.
     *
     * @param ica InstreamCompositeAddress to copy
     */
    InstreamCompositeAddress(const InstreamCompositeAddress& ica) throw();
    
    /** Virtual copy constructor.
     *
     * @return pointer to copied InstreamCompositeAddress
     */
    virtual InstreamCompositeAddress* copy() const throw();
    //@}
    
    /** @name Roles
     */
    //@{
    /** Sets the address to use for receiving one-way Buffers.
     *
     * 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
     */
    void setOneWayBufferReceiverAddress(int address_index) throw();
    
    /** Sets the address to use for receiving one-way CEvents.
     *
     * 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
     */
    void setOneWayCEventReceiverAddress(int address_index) throw();
    
    /** Sets the address to use for sending one-way Buffers.
     *
     * 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
     */
    void setOneWayBufferSenderAddress(int address_index) throw();
    
    /** Sets the address to use for sending one-way CEvents.
     *
     * 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
     */
    void setOneWayCEventSenderAddress(int address_index) throw();
    
    /** Returns the address to use for receiving one-way Buffers.
     *
     * This method returns the address assigned to a communication role.
     *
     * @return Index of child address to assign to this role
     */
    int getOneWayBufferReceiverAddress() const throw();
    
    /** Returns the address to use for receiving one-way CEvents.
     *
     * This method returns the address assigned to a communication role.
     *
     * @return Index of child address to assign to this role
     */
    int getOneWayCEventReceiverAddress() const throw();
    
    /** Returns the address to use for sending one-way Buffers.
     *
     * This method returns the address assigned to a communication role.
     *
     * @return Index of child address to assign to this role
     */
    int getOneWayBufferSenderAddress() const throw();
    
    /** Returns the address to use for sending one-way CEvents.
     *
     * This method returns the address assigned to a communication role.
     *
     * @return Index of child address to assign to this role
     */
    int getOneWayCEventSenderAddress() const throw();
    
    /** 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:
    /** Register all attributes for serialization.
     */
    void registerAttributes() throw();
    
  private:
    TValue<nmm_int32> __one_way_buffer_receiver_address;       ///< Address assigned to role for receiving one-way Buffers.
    TValue<nmm_int32> __one_way_cevent_receiver_address;       ///< Address assigned to role for receiving one-way Buffers.
    TValue<nmm_int32> __one_way_buffer_sender_address;         ///< Address assigned to role for sending one-way Buffers.
    TValue<nmm_int32> __one_way_cevent_sender_address;         ///< Address assigned to role for sending one-way Buffers.
  };
  
  
  inline void InstreamCompositeAddress::setOneWayBufferReceiverAddress(int address_index) throw() {
    __one_way_buffer_receiver_address.setValue(address_index);
  }
  
  inline void InstreamCompositeAddress::setOneWayCEventReceiverAddress(int address_index) throw() {
    __one_way_cevent_receiver_address.setValue(address_index);
  }
  
  inline void InstreamCompositeAddress::setOneWayBufferSenderAddress(int address_index) throw() {
    __one_way_buffer_sender_address.setValue(address_index);
  }
  
  inline void InstreamCompositeAddress::setOneWayCEventSenderAddress(int address_index) throw() {
    __one_way_cevent_sender_address.setValue(address_index);
  }
  
  inline int InstreamCompositeAddress::getOneWayBufferReceiverAddress() const throw() {
    return __one_way_buffer_receiver_address.getRValue();
  }
  
  inline int InstreamCompositeAddress::getOneWayCEventReceiverAddress() const throw() {
    return __one_way_cevent_receiver_address.getRValue();
  }
  
  inline int InstreamCompositeAddress::getOneWayBufferSenderAddress() const throw() {
    return __one_way_buffer_sender_address.getRValue();
  }
  
  inline int InstreamCompositeAddress::getOneWayCEventSenderAddress() const throw() {
    return __one_way_cevent_sender_address.getRValue();
  }
  
}

#include "nmm/nmm_suffix.hpp"

#endif
