//******************************************************************************
//
// Restricted Rights
// WARNING: This is a restricted distribution Zeligsoft file.
//
//******************************************************************************
//
// Copyright (C) 2006 Zeligsoft Inc. - All Rights Reserved
//

//******************************************************************************
//
//     FILE: zceCF_DeviceUsesPort.h
//
//******************************************************************************

#ifndef __ZCECF_DEVICEUSESPORT_H
#define __ZCECF_DEVICEUSESPORT_H


#if defined(OS_WIN32)
#pragma warning(disable:4786)
#endif

#include "zceOperatingEnvironment.h"

#include <string>

#include "CF_s.h"


#include "CF.h"


#define ZCECF_DEVICEUSESPORT_CARDINALITY_DEFAULT 1


class zceCF_DeviceUsesPort : public POA_CF::Port
{
	public : 
		zceCF_DeviceUsesPort( std::string name ZCE_EXC_ENV_ARG);

		virtual ~zceCF_DeviceUsesPort();

		/*!
		 * \brief Applications require the connectPort operation to establish associations
		 * between Ports. Ports provide channels through which data and/or control pass.
		 * The connectPort operation provides half of a two-way association; therefore two
		 * calls are required to create a two-way association.
		 *
		 * Specification reference:  3.1.3.1.1.5.1
		 *
		 * The connectPort operation shall make a connection to the component identified
		 * by its input parameters. A port may support several connections. The input
		 * connectionId is a unique identifier to be used by disconnectPort when breaking
		 * this specific connection.
		 *
		 * \return This operation does not return a value.
		 *
		 * \throw InvalidPort The connectPort operation shall raise the InvalidPort
		 * exception when the input connection parameter is an invalid connection for this
		 * Port.
		 *
		 * \throw OccupiedPort The connectPort operation shall raise the OccupiedPort
		 * exception when unable to accept the connections because the Port is already
		 * fully occupied.
		 *
		 */
		void connectPort ( CORBA::Object_ptr connection,  const char * connectionId ZCE_EXC_ENV_ARG)
			throw ( CORBA::SystemException, CF::Port::InvalidPort, CF::Port::OccupiedPort );

		/*!
		 * \brief Applications require the disconnectPort operation in order to allow
		 * consumer/producer data components to disassociate themselves from their
		 * counterparts (consumer/producer).
		 *
		 * Specification reference:  3.1.3.1.1.5.2
		 *
		 * The disconnectPort operation shall break the connection to the component
		 * identified by the input parameter.
		 *
		 * \return This operation does not return a value.
		 *
		 * \throw InvalidPort The disconnectPort operation shall raise the InvalidPort
		 * exception when the name passed to disconnectPort is not connected with the Port
		 * component.
		 *
		 */
		void disconnectPort ( const char * connectionId ZCE_EXC_ENV_ARG)
			throw ( CORBA::SystemException , CF::Port::InvalidPort );


		/*!	\brief
		 *
		 *	 Describe operation here.
		 * 
		 *	\param capacities ( ::CF::Properties ) 
		 * 
		 *	\throw ::CF::Device::InvalidCapacity
		 * 
		 *	\throw ::CF::Device::InvalidState
		 * 
		 */
		CORBA::Boolean allocateCapacity( const CF::Properties& capacities ZCE_EXC_ENV_ARG );

		/*!	\brief
		 *
		 *	 Describe operation here.
		 * 
		 *	\param capacities ( ::CF::Properties ) 
		 * 
		 *	\throw ::CF::Device::InvalidCapacity
		 * 
		 *	\throw ::CF::Device::InvalidState
		 * 
		 */
		void deallocateCapacity( const CF::Properties& capacities ZCE_EXC_ENV_ARG );

		CF::Device::UsageType usageState( ZCE_EXC_ENV_SINGLE_ARG );

		CF::Device::AdminType adminState( ZCE_EXC_ENV_SINGLE_ARG );

		void adminState( CF::Device::AdminType value  ZCE_EXC_ENV_ARG);

		CF::Device::OperationalType operationalState( ZCE_EXC_ENV_SINGLE_ARG );

		char* softwareProfile( ZCE_EXC_ENV_SINGLE_ARG );

		char* label( ZCE_EXC_ENV_SINGLE_ARG );

		CF::AggregateDevice_ptr compositeDevice( ZCE_EXC_ENV_SINGLE_ARG );

		/*!
		 * \brief The getPort operation provides a mechanism to obtain a specific consumer
		 * or producer Port. A PortSupplier may contain zero-to-many consumer and producer
		 * port components. The exact number is specified in the component’s Software
		 * Profile SCD (section 3.1.3.4). Multiple input and/or output ports provide
		 * flexibility for PortSuppliers that must manage varying priority levels and
		 * categories of incoming and outgoing messages, provide multi-threaded message
		 * handling, or other special message processing.
		 *
		 * Specification reference:  3.1.3.1.4.5.1
		 *
		 * The getPort operation returns the object reference to the named port as stated
		 * in the component's SCD.
		 *
		 * \param name (string ) The name of the port being requested.
		 *
		 * \return The getPort operation shall return the CORBA object reference that is
		 * associated with the input port name.
		 *
		 * \throw UnknownPort The getPort operation shall raise an UnknownPort exception
		 * if the port name is invalid.
		 *
		 */
		CORBA::Object_ptr getPort( const char* name ZCE_EXC_ENV_ARG );

		/*!
		 * \brief The start operation is provided to command a Resource implementing this
		 * interface to start internal processing.
		 *
		 * Specification reference:  3.1.3.1.6.5.2
		 *
		 * The start operation puts the Resource in an operating condition.
		 *
		 * \return This operation does not return a value.
		 *
		 * \throw StartError The start operation shall raise the StartError exception if
		 * an error occurs while starting the resource.
		 *
		 */
		void start( ZCE_EXC_ENV_SINGLE_ARG );

		/*!
		 * \brief The stop operation is provided to command a Resource implementing this
		 * interface to stop internal processing.
		 *
		 * Specification reference:  3.1.3.1.6.5.1
		 *
		 * The stop operation shall disable all current operations and put the Resource in
		 * a non-operating condition. Subsequent configure, query, and start operations
		 * are not inhibited by the stop operation.
		 *
		 * \return This operation does not return a value.
		 *
		 * \throw StopError The stop operation shall raise the StopError exception if an
		 * error occurs while stopping the resource.
		 *
		 */
		void stop( ZCE_EXC_ENV_SINGLE_ARG );

		char* identifier( ZCE_EXC_ENV_SINGLE_ARG );

		/*!
		 * \brief The configure operation allows id/value pair configuration properties to
		 * be assigned to components implementing this interface.
		 *
		 * Specification reference:  3.1.3.1.5.5.1
		 *
		 * The configure operation shall assign values to the properties as indicated in
		 * the configProperties argument. Valid properties for the configure operation
		 * shall at a minimum be the configure readwrite and writeonly properties
		 * referenced in the component's SPD.
		 *
		 * \param configProperties (::CF::Properties ) 
		 *
		 * \return This operation does not return a value.
		 *
		 * \throw PartialConfiguration The configure operation shall raise a
		 * PartialConfiguration exception when some configuration properties were
		 * successfully set and some configuration properties were not successfully set.
		 *
		 * \throw InvalidConfiguration The configure operation shall raise an
		 * InvalidConfiguration exception when a configuration error occurs that prevents
		 * any property configuration on the component.
		 *
		 */
		void configure( const CF::Properties& configProperties ZCE_EXC_ENV_ARG );

		/*!
		 * \brief The query operation allows a component to be queried to retrieve its
		 * properties.
		 *
		 * Specification reference:  3.1.3.1.5.5.2
		 *
		 * The query operation shall return all component properties if the
		 * configProperties are zero size.
		 *
		 * The query operation shall return only those id/value pairs specified in the
		 * configProperties if the configProperties are not zero size. Valid properties
		 * for the query operation shall at a minimum be the configure, readwrite, and
		 * readonly properties, and allocation properties that have an action value of
		 * "external" as referenced in the component's SPD.
		 *
		 * \param configProperties (::CF::Properties ) 
		 *
		 * \return This operation does not return a value.
		 *
		 * \throw  The query operation shall raise the CF UnknownProperties exception when
		 * one or more properties being requested are not known by the component.
		 *
		 */
		void query( CF::Properties& configProperties ZCE_EXC_ENV_ARG );

		/*!
		 * \brief The runTest operation allows components to be "blackbox" tested. This
		 * allows Built-In Test (BIT) to be implemented and this provides a means to
		 * isolate faults (both software and hardware) within the system.
		 *
		 * Specification reference:  3.1.3.1.3.5.1
		 *
		 * The runTest operation shall use the testId parameter to determine which of its
		 * predefined test implementations should be performed. The testValues parameter
		 * CF Properties (id/value pair(s)) shall be used to provide additional
		 * information to the implementation-specific test to be run. The runTest
		 * operation shall return the result(s) of the test in the testValues parameter.
		 *
		 * \param testId (unsigned long ) Use the testId parameter to determine which of
		 * its predefined test implementations should be performed
		 *
		 * \param testValues (::CF::Properties ) The testValues parameter CF Properties
		 * (id/value pair(s)) shall be used to provide additional information to the
		 * implementation-specific test to be run. The runTest operation shall return the
		 * result(s) of the test in the testValues parameter.
		 *
		 * \return The runTest operation shall return the result(s) of the test in the
		 * testValues parameter.
		 *
		 * \throw UnknownTest The runTest operation shall raise the UnknownTest exception
		 * when there is no underlying test implementation that is associated with the
		 * input testId given.
		 *
		 * \throw UnknownProperties The runTest operation shall raise the
		 * UnknownProperties exception when the input parameter testValues contains any
		 * DataTypes that are not known by the component's test implementation or any
		 * values that are out of range for the requested test. 
		 *
		 */
		void runTest( CORBA::ULong testid, CF::Properties& testValues ZCE_EXC_ENV_ARG );

		/*!	\brief
		 *
		 *	 Describe operation here.
		 * 
		 *	\throw ::CF::LifeCycle::InitializeError
		 * 
		 */
		void initialize( ZCE_EXC_ENV_SINGLE_ARG );

		/*!	\brief
		 *
		 *	 Describe operation here.
		 * 
		 *	\throw ::CF::LifeCycle::ReleaseError
		 * 
		 */
		void releaseObject( ZCE_EXC_ENV_SINGLE_ARG );


		bool is_connected(ZCE_EXC_ENV_SINGLE_ARG);



	private : 
		::CF::Device_var port_;

		std::string name_; // the name of the port

		std::string connectionId_; // the id of the connection that the port is involved in

		short consCount_; // a count of the number of consumers connected to the port

		short cardinality_; // the maximum number of connections accepted by this port


};
#endif     // __ZCECF_DEVICEUSESPORT_H

// End-Of-File
//------------------------------------------------------------------------------
