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

//******************************************************************************
//
//     FILE: zceReadDataWorker.h
//
//******************************************************************************

#ifndef __ZCEREADDATAWORKER_H
#define __ZCEREADDATAWORKER_H


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <fstream>
#include <sys/stat.h>

#include "PortTypes.h"

#include "zceOperatingEnvironment.h"

#include "zceReadDataServant.h"


#include "zcePushPorts_OctetSeqConsumerUsesPort.h"

class zceReadDataWorker
{

	public:

		void workerThreadFunc();

		zceReadDataWorker( const ReadData_params& execParams , zcePushPorts_OctetSeqConsumerUsesPort* portDataOut ZCE_EXC_ENV_ARG );

		virtual ~zceReadDataWorker();

		void setportDataOut( zcePushPorts_OctetSeqConsumerUsesPort& portDataOut );

		void initExecParams( const ReadData_params& params ZCE_EXC_ENV_ARG);

		void config_propInputFilePath( const CORBA::String_var& propinputfilepath ZCE_EXC_ENV_ARG );

		void config_propApplicationType( const CORBA::Long& propapplicationtype ZCE_EXC_ENV_ARG );


		void query_propInputFilePath( CORBA::String_var& propinputfilepath ZCE_EXC_ENV_ARG );

		void query_propApplicationType( CORBA::Long& propapplicationtype ZCE_EXC_ENV_ARG );



		/*!	\brief
		 *
		 *	 Describe operation here.
		 *
		 *	\throw ::CF::LifeCycle::InitializeError
		 *
		 */
		virtual void CF_LifeCycle_initialize( int portIdentifier ZCE_EXC_ENV_ARG );

		/*!	\brief
		 *
		 *	 Describe operation here.
		 *
		 *	\throw ::CF::LifeCycle::ReleaseError
		 *
		 */
		virtual void CF_LifeCycle_releaseObject( int portIdentifier 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.
		 *
		 */
		virtual void CF_Resource_start( int portIdentifier ZCE_EXC_ENV_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.
		 *
		 */
		virtual void CF_Resource_stop( int portIdentifier ZCE_EXC_ENV_ARG );


		#if defined(DEBUG_MSGS)
		void setDebugStream(const std::ostream& stream);

		void debugMsg(const std::string&);
		#endif

	private:
		zcePushPorts_OctetSeqConsumerUsesPort* portDataOut_;


		ReadData_params execParams_;

		pthread_t mThreadId;
		int mIsStarted;
		int mIsDone;
		bool mIsThreadRunning;
		long mPacketID;
		CORBA::Long mPropApplicationType; ///< ApplicationType property (0 = voice, 1 = data)
		CORBA::String_var mPropInputFilePath;
		char* mInputFilePath;

		#if defined(DEBUG_MSGS)
		std::ostream debug_;
		#endif

};
#endif     // __ZCEREADDATAWORKER_H

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