secureswitools/swisistools/source/sisxlibrary/sisdata.h
changeset 0 ba25891c3a9e
child 26 04d4a7bbc3e0
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2004-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 "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 * As specified in SGL.GT0188.251
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file 
       
    22  @publishedPartner
       
    23  @released
       
    24 */
       
    25 
       
    26 #ifndef __SISDATA_H__
       
    27 #define __SISDATA_H__
       
    28 
       
    29 
       
    30 #include "sisdataunit.h"
       
    31 #include "sisarray.h"
       
    32 
       
    33 
       
    34 /**
       
    35  * CSISData is collection of CSISDataUnit class. And CSISData is
       
    36  * part of CSISContents.
       
    37  */
       
    38 class CSISData : public CStructure <CSISFieldRoot::ESISData>
       
    39 	{
       
    40 private:
       
    41 	typedef CSISArray <CSISDataUnit, CSISFieldRoot::ESISDataUnit> TDataUnit;
       
    42 
       
    43 public:
       
    44 	typedef TDataUnit::TMemberCount TDataUnitCount;
       
    45 
       
    46 public:
       
    47 	/**
       
    48 	 * Default constructor
       
    49 	 */
       
    50 	CSISData ();
       
    51 	/**
       
    52 	 * Copy Constructor
       
    53 	 */
       
    54 	CSISData (const CSISData& aInitialiser);
       
    55 	/**
       
    56 	 * Class Name
       
    57 	 */
       
    58 	virtual std::string Name () const;
       
    59 	/**
       
    60 	 * Reads the stream and internalize the class.
       
    61 	 * @param aFile Stream to be read.
       
    62 	 * @param aContainerSize size of the content to be read.
       
    63 	 * @param aArrayType Type of array. ESISUndefined if its not an array  
       
    64 	 */
       
    65 	virtual void Read (TSISStream& aFile, const CSISFieldRoot::TFieldSize& aContainerSize, const CSISFieldRoot::TFieldType aArrayType = CSISFieldRoot::ESISUndefined);
       
    66 
       
    67 	/**
       
    68 	 * Read the file and add the content into the last sisdataunit's last file.
       
    69 	 * @param aFile file to be read.
       
    70 	 */
       
    71 	TUint32 LoadFile (const std::wstring& aFile, TUint64* aSize = NULL);
       
    72 	/**
       
    73 	 * Get the CSISDataUnit object specified by the index.
       
    74 	 * @param aUnit - index of the data unit required.
       
    75 	 * @param const reference to CSISDataUnit class.
       
    76 	 */
       
    77 	const CSISDataUnit& GetDataUnit (const TDataUnitCount aUnit) const;
       
    78 	/**
       
    79 	 * Get the CSISDataUnit object specified by the index.
       
    80 	 * @param aUnit - index of the data unit required.
       
    81 	 * @param reference to CSISDataUnit class.
       
    82 	 */
       
    83 	CSISDataUnit& GetDataUnit (const TDataUnitCount aUnit);
       
    84 	/**
       
    85 	 * Add a new data unit into CSISData.
       
    86 	 */
       
    87 	TDataUnitCount AddDataUnit (const CSISDataUnit& aUnit);
       
    88 	/**
       
    89 	 * Append DataUnits present the passed CSISData.
       
    90 	 */
       
    91 	TDataUnitCount AppendData (const CSISData& aData);
       
    92 	/**
       
    93 	 * Add a new SISDataUnit into the existing list.
       
    94 	 */
       
    95 	void SetDefaultContent ();
       
    96 	/**
       
    97 	 * Checks if there is any data in the sis. i.e. it checks whether
       
    98 	 * there any SISDataUnit present in the sis.
       
    99 	 * @return true if data is present else false.
       
   100 	 */
       
   101 	bool DataPresent() const;
       
   102 	/**
       
   103 	 * Returns the compressed size of the last data unit's last file.
       
   104 	 */
       
   105 	TUint64 CompressedSize () const;
       
   106 	/**
       
   107 	 * Returns the un-compressed size of the last data unit's last file.
       
   108 	 */
       
   109 	TUint64 UncompressedSize () const;
       
   110 	/**
       
   111 	 * Retrievs a specific data unit. In case of invalid index the function
       
   112 	 * will throw an exception.
       
   113 	 * @param aUnit Index into SISData which uniquely selects a SISDataUnit
       
   114 	 * @return return the reference to the SISDataUnit obect.
       
   115 	 */
       
   116 	const CSISDataUnit& DataUnit (const TDataUnitCount aUnit) const;
       
   117 	/**
       
   118 	 * Retrievs a specific data unit. In case of invalid index the function
       
   119 	 * will throw an exception.
       
   120 	 * @param aUnit Index into SISData which uniquely selects a SISDataUnit
       
   121 	 * @return return the reference to the SISDataUnit obect.
       
   122 	 */
       
   123 	CSISDataUnit& DataUnit (const TDataUnitCount aUnit);
       
   124 
       
   125 	/**
       
   126 	 * Set the state of SISData to Stub. And clears the data unit present in it.
       
   127 	 */
       
   128 	void SetStub ();
       
   129 	/**
       
   130 	 * Checks if the SISData is of a stub or not.
       
   131 	 */
       
   132 	bool Stub () const;
       
   133 	/**
       
   134 	 * Adds the write the package details into the stream.
       
   135 	 * @param aStream - Stream in which the package entries need to be written.
       
   136 	 * @param aVerbose - If this option is set then detail description of pkg
       
   137 	 * 			will be written into the stream.
       
   138 	 */
       
   139 	void AddPackageEntry(std::wostream& aStream, bool aVerbose) const;
       
   140 	/**
       
   141 	 * Retrieve the data unit count present in this SISData.
       
   142 	 */
       
   143 	inline TDataUnitCount DataUnitCount() const;
       
   144 
       
   145 private:
       
   146 	void InsertMembers ();
       
   147 
       
   148 private:
       
   149 	TDataUnit	iDataUnit;
       
   150 	bool		iStub;
       
   151 	};
       
   152 
       
   153 
       
   154 inline void CSISData::InsertMembers ()
       
   155 	{
       
   156 	InsertMember (iDataUnit);
       
   157 	}
       
   158 
       
   159 inline CSISData::CSISData () :
       
   160 		iStub (false)
       
   161 	{ 
       
   162 	InsertMembers (); 
       
   163 	}
       
   164 
       
   165 
       
   166 inline CSISData::CSISData (const CSISData& aInitialiser) :
       
   167 		CStructure <CSISFieldRoot::ESISData> (aInitialiser),
       
   168 		iDataUnit (aInitialiser.iDataUnit),
       
   169 		iStub (aInitialiser.iStub)
       
   170 	{ 
       
   171 	InsertMembers (); 
       
   172 	}
       
   173 
       
   174 
       
   175 inline TUint32 CSISData::LoadFile (const std::wstring& aFile, TUint64* aSize)
       
   176 	{
       
   177 	return iDataUnit.Last ().LoadFile (aFile, aSize); 
       
   178 	}
       
   179 
       
   180 
       
   181 inline const CSISDataUnit& CSISData::DataUnit (const TDataUnitCount aUnit) const
       
   182 	{
       
   183 	return iDataUnit [aUnit];
       
   184 	}
       
   185 
       
   186 
       
   187 inline CSISDataUnit& CSISData::DataUnit (const TDataUnitCount aUnit)
       
   188 	{
       
   189 	return iDataUnit [aUnit];
       
   190 	}
       
   191 
       
   192 
       
   193 inline CSISData::TDataUnitCount CSISData::AddDataUnit (const CSISDataUnit& aUnit)
       
   194 	{ 
       
   195 	iDataUnit.Push (aUnit); 
       
   196 	return iDataUnit.size () - 1; 
       
   197 	}
       
   198 
       
   199 
       
   200 inline std::string CSISData::Name () const
       
   201 	{
       
   202 	return "Data";
       
   203 	}
       
   204 
       
   205 
       
   206 inline void CSISData::SetDefaultContent ()
       
   207 	{
       
   208 	iDataUnit.Push (CSISDataUnit ());
       
   209 	}
       
   210 
       
   211 inline bool CSISData::DataPresent () const
       
   212 	{
       
   213 	return (iDataUnit.size() != 0);
       
   214 	}
       
   215 	
       
   216 inline TUint64 CSISData::CompressedSize () const
       
   217 	{
       
   218 	return iDataUnit.Last ().CompressedSize ();
       
   219 	}
       
   220 
       
   221 
       
   222 inline TUint64 CSISData::UncompressedSize () const
       
   223 	{
       
   224 	return iDataUnit.Last ().UncompressedSize ();
       
   225 	}
       
   226 
       
   227 inline void CSISData::SetStub ()
       
   228 	{
       
   229 	iStub = true;
       
   230 	iDataUnit.clear ();
       
   231 	SetByteCount (0);
       
   232 	}
       
   233 
       
   234 inline bool CSISData::Stub () const
       
   235 	{
       
   236 	return iStub;
       
   237 	}
       
   238 
       
   239 inline CSISData::TDataUnitCount CSISData::DataUnitCount() const
       
   240 	{
       
   241 	return iDataUnit.size();
       
   242 	}
       
   243 
       
   244 #endif // __SISDATA_H__
       
   245