os/graphics/graphicstools/bitmapfonttools/inc/LST.H
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicstools/bitmapfonttools/inc/LST.H	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,160 @@
     1.4 +/*
     1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +* Header LST.H
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +#ifndef __LST_H__
    1.24 +#define __LST_H__
    1.25 +
    1.26 +template <class T>
    1.27 +class Link
    1.28 +/**
    1.29 +@publishedAll
    1.30 +WARNING: Class for internal use ONLY.  Compatibility is not guaranteed in future releases.
    1.31 +*/
    1.32 +	{
    1.33 +public:
    1.34 +	inline Link();
    1.35 +	inline Link(T aT);
    1.36 +public:
    1.37 +	Link* iNext;
    1.38 +	T iT;
    1.39 +	};
    1.40 +
    1.41 +template <class T>
    1.42 +class List
    1.43 +/**
    1.44 +@publishedAll
    1.45 +WARNING: Class for internal use ONLY.  Compatibility is not guaranteed in future releases.
    1.46 +*/
    1.47 +	{
    1.48 +public:
    1.49 +	inline List();
    1.50 +	inline int Size() const;
    1.51 +	inline T& operator [] (const int aNum) const;
    1.52 +	inline void Add(T aT);
    1.53 +	virtual void Externalize(ostream& out) = 0;
    1.54 +	inline void Destroy();
    1.55 +	inline ~List();
    1.56 +private:
    1.57 +	Link<T> *iFirst;
    1.58 +	};
    1.59 +
    1.60 +template <class T> 
    1.61 +class ObjectList : public List<T>
    1.62 +/**
    1.63 +List of object pointers
    1.64 +@publishedAll
    1.65 +WARNING: Class for internal use ONLY.  Compatibility is not guaranteed in future releases.
    1.66 +*/	
    1.67 +	{
    1.68 +public:
    1.69 +	inline virtual void Externalize(ostream& out);
    1.70 +	inline void Destroy();
    1.71 +	};
    1.72 +
    1.73 +template <class T> inline Link<T>::Link()
    1.74 +	{
    1.75 +	iNext = NULL;
    1.76 +	}
    1.77 +
    1.78 +template <class T> inline Link<T>::Link(T aT)
    1.79 +	{
    1.80 +	iT = aT;
    1.81 +	iNext = NULL;
    1.82 +	}
    1.83 +
    1.84 +template <class T> inline List<T>::List()
    1.85 +	{
    1.86 +	iFirst = NULL;
    1.87 +	}
    1.88 +
    1.89 +template <class T> inline int List<T>::Size() const
    1.90 +	{
    1.91 +	int size = 0;
    1.92 +	Link<T>* link = iFirst;
    1.93 +	while (link != NULL)
    1.94 +		{
    1.95 +		link = link->iNext;
    1.96 +		size++;
    1.97 +		}
    1.98 +	return size;
    1.99 +	}
   1.100 +
   1.101 +template <class T> inline T& List<T>::operator [] (const int aNum) const
   1.102 +	{
   1.103 +	int num = 0;
   1.104 +	Link<T>* link = iFirst;
   1.105 +	while (num != aNum)
   1.106 +		{
   1.107 +		link = link->iNext;
   1.108 +		num++;
   1.109 +		}
   1.110 +	return link->iT;
   1.111 +	}
   1.112 +
   1.113 +template <class T> inline void List<T>::Add(T aT)
   1.114 +	{
   1.115 +	Link<T>* link;
   1.116 +	if (iFirst == NULL)
   1.117 +		iFirst = new Link<T>(aT);
   1.118 +	else
   1.119 +		{
   1.120 +		link = iFirst;
   1.121 +		while (link->iNext != NULL)
   1.122 +			link = link->iNext; 
   1.123 +		link->iNext = new Link<T>(aT);
   1.124 +		}
   1.125 +	}
   1.126 +
   1.127 +template <class T> inline void List<T>::Destroy()
   1.128 +	{
   1.129 +	Link<T>* link = iFirst;
   1.130 +	Link<T>* next;
   1.131 +	while (link != NULL)
   1.132 +		{
   1.133 +		next = link->iNext;
   1.134 +		delete link;
   1.135 +		link = next;
   1.136 +		}
   1.137 +	iFirst = NULL;
   1.138 +	}
   1.139 +
   1.140 +template <class T> inline List<T>::~List (void)
   1.141 +	{
   1.142 +	Destroy();
   1.143 +	}
   1.144 +
   1.145 +template <class T> inline void ObjectList<T>::Externalize(ostream& out)
   1.146 +	{
   1.147 +	int32 size = List<T>::Size();
   1.148 +	int32 i;
   1.149 +	out.write ((char*) &size, sizeof(size));
   1.150 +	for (i = 0; i < size; i++)
   1.151 +		(*this)[i]->Externalize(out);
   1.152 +	}
   1.153 +
   1.154 +template <class T> inline void ObjectList<T>::Destroy()
   1.155 +	{
   1.156 +	int size = List<T>::Size();
   1.157 +	int i;
   1.158 +	for (i = 0; i < size; i++)
   1.159 +		delete (*this)[i];
   1.160 +	List<T>::Destroy();
   1.161 +	}
   1.162 +
   1.163 +#endif