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