Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

CProfileArray Class Reference

#include <profile.h>

List of all members.

Public Member Functions

 CProfileArray ()
 ~CProfileArray ()
unsigned Count () const
void Add (LPCTSTR lpstrNew)
CProfileoperator[] (unsigned u) const
void Remove (unsigned u)
void Empty ()

Private Member Functions

const unsigned ChunkSize () const
CProfileBorrow ()

Private Attributes

CProfilem_aStore [20]
CProfileArraym_pcpaNext
unsigned m_ucUsed


Constructor & Destructor Documentation

CProfileArray::CProfileArray  ) 
 

Definition at line 817 of file profile.cpp.

References m_aStore, m_pcpaNext, m_ucUsed, and NULL.

00817 { 00818 m_ucUsed = 0; 00819 m_pcpaNext = NULL; 00820 memset(m_aStore, 0, sizeof m_aStore); 00821 }

CProfileArray::~CProfileArray  ) 
 

Definition at line 823 of file profile.cpp.

References Empty().

00823 { 00824 Empty(); 00825 }


Member Function Documentation

void CProfileArray::Add LPCTSTR  lpstrNew  ) 
 

Definition at line 844 of file profile.cpp.

References Add(), ChunkSize(), m_aStore, m_pcpaNext, and m_ucUsed.

Referenced by Add(), CProfile::Enumerate(), and CDeviceProfileManagement::OnCommand().

00844 { 00845 _ASSERTE(lpstrNew && *lpstrNew); 00846 00847 if (m_ucUsed < ChunkSize()) { 00848 m_aStore[m_ucUsed++] = new CProfile(lpstrNew); 00849 return; 00850 } 00851 00852 // Not enough space! Add another record, if there isn't one 00853 00854 if (!m_pcpaNext) 00855 m_pcpaNext = new CProfileArray; 00856 00857 // Add the profile to the next array (recursive call!) 00858 00859 m_pcpaNext -> Add(lpstrNew); 00860 m_ucUsed++; 00861 }

CProfile * CProfileArray::Borrow  )  [private]
 

Definition at line 796 of file profile.cpp.

References ChunkSize(), m_aStore, m_pcpaNext, m_ucUsed, and NULL.

Referenced by Remove().

00796 { 00797 CProfile *pcpReturn = m_aStore[0]; 00798 00799 memcpy((LPSTR) m_aStore, (LPSTR) (m_aStore + 1), 00800 (ChunkSize() - 1) * sizeof m_aStore[0]); 00801 00802 if (m_ucUsed > ChunkSize()) 00803 m_aStore[ChunkSize() - 1] = m_pcpaNext -> Borrow(); 00804 else 00805 m_aStore[ChunkSize() - 1] = (CProfile *) NULL; 00806 00807 m_ucUsed--; 00808 00809 if (m_ucUsed <= ChunkSize() && m_pcpaNext) { 00810 delete m_pcpaNext; 00811 m_pcpaNext = NULL; 00812 } 00813 00814 return pcpReturn; 00815 }

const unsigned CProfileArray::ChunkSize  )  const [inline, private]
 

Definition at line 264 of file icmui/profile.h.

References m_aStore.

Referenced by Add(), Borrow(), Empty(), operator[](), and Remove().

00264 { 00265 return sizeof m_aStore / sizeof m_aStore[0]; 00266 }

unsigned CProfileArray::Count  )  const [inline]
 

Definition at line 275 of file icmui/profile.h.

References m_ucUsed.

Referenced by CMonitorProfileManagement::FillList(), CPrinterProfileManagement::FillList(), CDeviceProfileManagement::FillList(), CMonitorProfileManagement::InitList(), CPrinterProfileManagement::InitList(), CMonitorProfileManagement::OnCommand(), CPrinterProfileManagement::OnCommand(), CDeviceProfileManagement::OnCommand(), CMonitorProfileManagement::OnNotify(), CPrinterProfileManagement::OnNotify(), and CDeviceProfileManagement::OnNotify().

00275 { return m_ucUsed; }

void CProfileArray::Empty  ) 
 

Definition at line 827 of file profile.cpp.

References ChunkSize(), m_aStore, m_pcpaNext, m_ucUsed, and NULL.

Referenced by CProfile::Enumerate(), CDeviceProfileManagement::InitList(), and ~CProfileArray().

00827 { 00828 if (!m_ucUsed) return; 00829 00830 if (m_pcpaNext) { 00831 delete m_pcpaNext; 00832 m_pcpaNext = NULL; 00833 m_ucUsed = ChunkSize(); 00834 } 00835 00836 while (m_ucUsed--) 00837 delete m_aStore[m_ucUsed]; 00838 00839 m_ucUsed = 0; 00840 memset(m_aStore, 0, sizeof m_aStore); 00841 }

CProfile * CProfileArray::operator[] unsigned  u  )  const
 

Definition at line 863 of file profile.cpp.

References ChunkSize(), m_aStore, m_pcpaNext, and operator[]().

Referenced by operator[]().

00863 { 00864 return u < ChunkSize() ? 00865 m_aStore[u] : m_pcpaNext -> operator[](u - ChunkSize()); 00866 }

void CProfileArray::Remove unsigned  u  ) 
 

Definition at line 868 of file profile.cpp.

References Borrow(), ChunkSize(), m_aStore, m_pcpaNext, m_ucUsed, NULL, and Remove().

Referenced by CDeviceProfileManagement::OnCommand(), CDeviceProfileManagement::OnNotify(), and Remove().

00868 { 00869 00870 if (u > m_ucUsed) 00871 return; 00872 00873 if (u >= ChunkSize()) { 00874 m_pcpaNext -> Remove(u - ChunkSize()); 00875 return; 00876 } 00877 00878 delete m_aStore[u]; 00879 00880 memmove((LPSTR) (m_aStore + u), (LPSTR) (m_aStore + u + 1), 00881 (ChunkSize() - (u + 1)) * sizeof m_aStore[0]); 00882 00883 if (m_ucUsed > ChunkSize()) 00884 m_aStore[ChunkSize() - 1] = m_pcpaNext -> Borrow(); 00885 else 00886 m_aStore[ChunkSize() - 1] = (CProfile *) NULL; 00887 00888 m_ucUsed--; 00889 00890 if (m_ucUsed <= ChunkSize() && m_pcpaNext) { 00891 delete m_pcpaNext; 00892 m_pcpaNext = NULL; 00893 } 00894 }


Member Data Documentation

CProfile* CProfileArray::m_aStore[20] [private]
 

Definition at line 260 of file icmui/profile.h.

Referenced by Add(), Borrow(), ChunkSize(), CProfileArray(), Empty(), operator[](), and Remove().

CProfileArray* CProfileArray::m_pcpaNext [private]
 

Definition at line 261 of file icmui/profile.h.

Referenced by Add(), Borrow(), CProfileArray(), Empty(), operator[](), and Remove().

unsigned CProfileArray::m_ucUsed [private]
 

Definition at line 262 of file icmui/profile.h.

Referenced by Add(), Borrow(), Count(), CProfileArray(), Empty(), and Remove().


The documentation for this class was generated from the following files:
Generated on Sat May 15 19:46:27 2004 for test by doxygen 1.3.7