realtimenetprots/sipfw/SDP/api/SdpRepeatField.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Name          : SdpRepeatField.h
       
    16 * Part of       : SDP Codec
       
    17 * Interface     : SDK API, SDP Codec API
       
    18 * Version       : 1.0
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 #ifndef CSDPREPEATFIELD_H
       
    25 #define CSDPREPEATFIELD_H
       
    26 
       
    27 //  INCLUDES
       
    28 #include <e32base.h>
       
    29 #include <stringpool.h>
       
    30 #include <sdptypedtime.h>
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class RReadStream;
       
    34 class RWriteStream;
       
    35 
       
    36 // CLASS DECLARATION
       
    37 /**
       
    38  *  @publishedAll
       
    39  *  @released
       
    40  *
       
    41  *	This class encapsulates the repeat times field of the 
       
    42  *  Session Description Protocol.
       
    43  *
       
    44  *	The normative reference for correct formatting and values is
       
    45  *	draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
       
    46  *  member documentation. The implementation supports this normative
       
    47  *  reference, but does not enforce it fully. 
       
    48  *
       
    49  *  @lib sdpcodec.lib
       
    50  */
       
    51 class CSdpRepeatField : public CBase
       
    52 	{
       
    53     public: // Constructors and destructor
       
    54         /**
       
    55          *	Constructs a new repeat times field.
       
    56 		 *	
       
    57          *	@param aText A string containing a correctly 
       
    58          *         formatted field value terminated by a CRLF.
       
    59          *	@return a new instance.
       
    60          */
       
    61 		IMPORT_C static	CSdpRepeatField* DecodeL(const TDesC8& aText);
       
    62 
       
    63         /**
       
    64          *	Constructs a new repeat times field and adds the pointer to the 
       
    65          *  cleanup stack.
       
    66 		 *	
       
    67          *	@param aText A string containing a correctly 
       
    68          *         formatted field value terminated by a CRLF.
       
    69          *	@return a new instance.
       
    70          */
       
    71 		IMPORT_C static	CSdpRepeatField* DecodeLC(const TDesC8& aText);
       
    72 
       
    73         /**
       
    74          *	Constructs a new repeat times field.
       
    75 		 *	
       
    76          *	@param aRepeatInterval Repeat interval value 
       
    77          *         greater than zero.
       
    78          *	@param aActiveDuration Active duration.
       
    79          *	@param aOffsets At least one time offset.
       
    80          *	@return a new instance.
       
    81          */
       
    82 		IMPORT_C static	CSdpRepeatField* NewL(
       
    83                                         const TSdpTypedTime  aRepeatInterval,
       
    84 										const TSdpTypedTime  aActiveDuration,
       
    85 										const RArray<TSdpTypedTime>& aOffsets);
       
    86 
       
    87         /**
       
    88          *	Constructs a new repeat times field and adds the pointer to the 
       
    89          *  cleanup stack.
       
    90 		 *	
       
    91          *	@param aRepeatInterval Repeat interval value 
       
    92          *         greater than zero.
       
    93          *	@param aActiveDuration Active duration.
       
    94          *	@param aOffsets At least one time offset.
       
    95          *	@return a new instance.
       
    96          */
       
    97 		IMPORT_C static	CSdpRepeatField* NewLC(
       
    98                                         const TSdpTypedTime  aRepeatInterval,
       
    99 										const TSdpTypedTime aActiveDuration,
       
   100 										const RArray<TSdpTypedTime>& aOffsets);
       
   101 
       
   102 		/**
       
   103 		 *	Deletes the resources held by the instance.
       
   104 		 */
       
   105 		IMPORT_C ~CSdpRepeatField();
       
   106 
       
   107     public: // New functions
       
   108 		/**
       
   109 		 *	Outputs the field formatted according to SDP syntax and including
       
   110 		 *  the terminating CRLF.
       
   111 		 * 
       
   112 		 *	@param aStream Stream used for output. On return 
       
   113          *         the stream includes correctly formatted repeat field.
       
   114 		 */
       
   115 		IMPORT_C void EncodeL(RWriteStream& aStream) const;
       
   116 
       
   117 		/**
       
   118 		 *	Creates a new instance that is equal to the target.
       
   119 		 *
       
   120 		 *	@return a new instance.
       
   121 		 */
       
   122 		IMPORT_C CSdpRepeatField * CloneL() const;
       
   123 
       
   124 		/**	
       
   125 		 *	Compares this instance to another for equality.
       
   126 		 *
       
   127 		 *	@param aObj The instance to compare to.
       
   128 		 *	@return ETrue if equal, EFalse if not.
       
   129 		 */
       
   130 		IMPORT_C TBool operator == (const CSdpRepeatField & aObj) const;
       
   131 
       
   132 		/**
       
   133 		 *	Gets the repeat interval.
       
   134 		 *
       
   135 		 *	@return The repeat interval.
       
   136 		 */
       
   137 		IMPORT_C const TSdpTypedTime RepeatInterval() const;
       
   138 
       
   139 		/**
       
   140 		 *	Sets the repeat interval.
       
   141 		 *
       
   142          *	@param aValue Repeat interval value greater than zero.
       
   143          *	@leave KErrSdpCodecRepeatField if aValue is not positive integer 
       
   144          *         value.
       
   145 		 */
       
   146 		IMPORT_C void SetRepeatIntervalL(const TSdpTypedTime  aValue);
       
   147 
       
   148 		/**
       
   149 		 *	Gets the active duration..
       
   150 		 *
       
   151 		 *	@return The active duration.
       
   152 		 */
       
   153 		IMPORT_C const TSdpTypedTime ActiveDuration() const;
       
   154 
       
   155 		/**
       
   156 		 *	Sets the active duration.
       
   157 		 *
       
   158          *	@param Active duration.
       
   159 		 */
       
   160 		IMPORT_C void SetActiveDuration(const TSdpTypedTime aValue);
       
   161 
       
   162 		/**
       
   163 		 *	Gets the array of time offsets.
       
   164 		 *  This array is used directly for element insertion and removal.
       
   165 		 *
       
   166 		 *	@return The offsets.
       
   167 		 */
       
   168 		IMPORT_C const RArray<TSdpTypedTime>& TimeOffsets() const;
       
   169 
       
   170 		/**
       
   171 		 *	Sets the time offsets.
       
   172 		 *
       
   173          *	@param aOffsets At least one time offset.
       
   174 		 */
       
   175 		IMPORT_C void SetTimeOffsetsL(const RArray<TSdpTypedTime>& aValue);
       
   176 
       
   177     public:
       
   178 		/**
       
   179          *  Externalizes the object to stream
       
   180          *
       
   181          *  @param aStream Stream where the object's state will be stored
       
   182          */
       
   183 		void ExternalizeL(RWriteStream& aStream) const;
       
   184 		
       
   185 		/**
       
   186          *  Creates object from the stream data
       
   187          *
       
   188          *  @param aStream Stream where the object's state will be read	
       
   189          *  @return Initialized object
       
   190          */
       
   191 		static CSdpRepeatField* InternalizeL(RReadStream& aStream);
       
   192 
       
   193 	private:
       
   194 		CSdpRepeatField(const TSdpTypedTime aRepeatInterval,
       
   195 						const TSdpTypedTime aActiveDuration);
       
   196 		CSdpRepeatField();
       
   197 		void ConstructL(const TDesC8& aText);
       
   198 		void ConstructL(const RArray<TSdpTypedTime>& aOffsets);
       
   199         
       
   200 
       
   201     private: // Data
       
   202         RStringPool iPool;
       
   203 		TSdpTypedTime iRepeatInterval;
       
   204 		TSdpTypedTime iActiveDuration;
       
   205 		RArray<TSdpTypedTime> iTimeOffsets;
       
   206 
       
   207 		void __DbgTestInvariant() const;
       
   208 	
       
   209 	};
       
   210 
       
   211 #endif // CSDPREPEATFIELD_H