Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

SLDeviceList Class Reference
[segusoland C++ Library]

Holds a list of SLDevice instances. More...

#include <SLDeviceList.hpp>

Collaboration diagram for SLDeviceList:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SLDeviceList (unsigned int initial_capacity)
const SLDeviceoperator[] (unsigned int index)
void push_back (const SLDevice &dev)
unsigned int size ()
void sort ()

Protected Attributes

boost::shared_ptr< Data > _shared_ptr
bool _isSorted

Detailed Description

Holds a list of SLDevice instances.

Author:
Alexandre Sauve
See also:
SLDevice
SLString uses shared_ptr, see the Library section for details.

This class is optimized for fast copy by value.

Example of code :

#include "SLDeviceList.hpp" SLDeviceList list(100); // builds an empty list with initial capacity of 100 list.push_back(SLDevice("HDD", "/dev/hda1")); SLDevice dev = list[0]; // access 1st element of the list list[0] = SLDevice("My CDWriter", "/dev/cdrecord"); // no pointer at all // no need to call delete anywhere


Constructor & Destructor Documentation

SLDeviceList::SLDeviceList unsigned int  initial_capacity  ) 
 

Build the list with an initial capacity. The initial_capacity allow to avoid frequent reallocations.


Member Function Documentation

const SLDevice& SLDeviceList::operator[] unsigned int  index  ) 
 

The [] operator allow to read and write to the list as it was an array.

Returns:
a SLDevice that is leak-proof.

void SLDeviceList::push_back const SLDevice dev  ) 
 

This function works like std::vector. There is no memory allocation while the size of the list remains bellow the initial capacity.

unsigned int SLDeviceList::size  ) 
 

Gets the size of the list.

Returns:
the current number of inserted items.

void SLDeviceList::sort  ) 
 

The list is unsorted by default. So this function does this work.

Note: If called more than once, the sort done only one time.


Member Data Documentation

bool SLDeviceList::_isSorted [protected]
 

This variables is true after the 1st call to sort()

boost::shared_ptr<Data> SLDeviceList::_shared_ptr [protected]
 

This variable hold the various data used by the string in an efficient and memory leaks proof way.


The documentation for this class was generated from the following file:
Generated on Mon Apr 19 01:03:35 2004 for segusoLand by doxygen 1.3.6-20040222