Click here to Skip to main content
15,895,192 members
Articles / Programming Languages / Visual C++ 10.0

SIP Stack (1 of 3)

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
20 Aug 2012CPOL3 min read 30.1K   1.7K   4  
SIP Stack Implementation on the basis of RFC SIP 3261 Specification
#pragma once

#ifndef CTimerProcessor_h
	#define CTimerProcessor_h

	#include <boost/thread/thread.hpp>

	#include "AMessageTarget.h"
	#include "AObserverSubject.h"
	#include "ASyncronizationClass.h"
	
	#include "CSortedBinaryTree.h"
	#include "CTimerDataItem.h"
	#include "AMessageHandler.h"

	namespace CoreFW
	{
		class CORE_DLL_DECLARATION_SPECIFIER CTimerProcessor : public AMessageTarget, public AObserverSubject
		{
		protected:
			CTimerProcessor() ;
		public:
			CTimerProcessor( RESOURCE_ID_TYPE ResourceID, const std::string &strResourceName, 
								unsigned long ulTimerWaitTimeInMSec, AApplication *pApplication ) ;
			virtual ~CTimerProcessor() ;
		
		public:
			FW_RETURN_TYPE SetTimer( AMessageHandler *pTimerHandler, long lTimerID, __int64 i64ElapsedTimeInMSec,
										AMessageData *pMessageData = NULL ) ;
			FW_RETURN_TYPE KillTimer( AMessageHandler *pTimerHandler, long lTimerID ) ;
			FW_RETURN_TYPE KillTimer( CTimerDataItem *pTimerDataItem ) ;
			FW_RETURN_TYPE KillTimerAll( AMessageHandler *pTimerHandler ) ;
	
			FW_RETURN_TYPE Start() ;
			FW_RETURN_TYPE Stop() ;

			void ProcessTimerData() ;

			void SetTimerWaitTimeInMSec( unsigned long ulTimerWaitTimeInMSec ) ;
			unsigned long GetTimerWaitTimeInMSec() const ;

			void SetEnableLogFromTimerProcessorThread( bool bEnableLogFromTimerProcessorThread ) ;
			bool GetEnableLogFromTimerProcessorThread() ;

			bool IsRunning() const ;

			int GetSize() ;

			FW_RETURN_TYPE GetTimerUsage( ALogger *pLogger ) ;

		private:
			void ReleaseTimerDataItems() ;
			FW_RETURN_TYPE KillTimerWithoutSync( AMessageHandler *pTimerHandler, long lTimerID ) ;
					
		protected:
			FW_RETURN_TYPE StartTimerThread() ;

		private:
			ASyncronizationClass *m_pTimerDataItemSyncObject ;
			EnumProcessorState m_eProcessorState ;
			boost::thread *m_pTimerProcessorThread ;

			unsigned long m_ulTimerWaitTimeInMSec ;

			CSortedBinaryTree<CTimerDataItem> m_SortedBinaryTree ;

			bool m_bEnableLogFromTimerProcessorThread ;
		} ;

		inline void CTimerProcessor::SetEnableLogFromTimerProcessorThread( bool bEnableLogFromTimerProcessorThread )
		{
			m_bEnableLogFromTimerProcessorThread = bEnableLogFromTimerProcessorThread ;
		}

		inline bool CTimerProcessor::GetEnableLogFromTimerProcessorThread()
		{
			return m_bEnableLogFromTimerProcessorThread ;
		}

		inline bool CTimerProcessor::IsRunning() const
		{
			return ( m_eProcessorState == PROCESSOR_STATE_RUNNING ) ;
		}

		inline void CTimerProcessor::SetTimerWaitTimeInMSec( unsigned long ulTimerWaitTimeInMSec )
		{
			m_ulTimerWaitTimeInMSec = ulTimerWaitTimeInMSec ;
		}

		inline unsigned long CTimerProcessor::GetTimerWaitTimeInMSec() const
		{
			return m_ulTimerWaitTimeInMSec ;
		}

	} // End namespace

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
India India
Hatim Haidry

VC++, Technical Architect

India

haidryhatim@gmail.com

Comments and Discussions