DumontEXE 0.0.1
DumontObject.cpp
00001 
00002 #include "DumontObject.h"
00003 
00004 long DumontObject::s_instanceCount = 0;
00005 
00006 DumontObject::DumontObject( const DumontObject & copy )
00007 :
00008   QObject( copy.parent() )
00009 {
00010   setName( copy.name() );
00011 //  qDebug( "DumontObject(\"%s\")", name().toAscii().data() );
00012 
00013   s_instanceCount++;
00014 }
00015 
00016 DumontObject::DumontObject( QObject * parent )
00017 :
00018   QObject( parent )
00019 {
00020 //  qDebug( "DumontObject parent %p", parent );
00021   s_instanceCount++;
00022 }
00023 
00024 DumontObject::~DumontObject()
00025 {
00026 //  qDebug( "~DumontObject(\"%s\")", name().toAscii().data() );
00027   s_instanceCount--;
00028 }
00029 
00030 QString DumontObject::name(void) const
00031 {
00032   return( m_name );
00033 }
00034 
00035 void DumontObject::setName( const QString & i_name )
00036 {
00037   m_name = i_name;
00038 }
00039 
00040 long DumontObject::instanceCount() const
00041 {
00042   return( s_instanceCount );
00043 }
00044 
00045 
00046 
00047 
00048 DumontObjects::DumontObjects( QObject * parent ):
00049   DumontObject(parent)
00050 {
00051 }
00052 
00053 DumontObjects::~DumontObjects()
00054 {
00055 }
00056 
00057 long DumontObjects::count(void)
00058 {
00059   return( m_objects.count() );
00060 }
00061 
00062 long DumontObjects::add( DumontObject * object )
00063 {
00064   /*
00065   ** Add the object to the list of objects.
00066   **
00067   */
00068   m_objects.append( object );
00069 
00070   /*
00071   ** Connect a destroyed signal to the list so that if the object is destroyed
00072   **  it is automatically removed from the list of pointers.
00073   **
00074   */
00075   connect( object, SIGNAL(destroyed(QObject*)), this, SLOT(on_objectDestroyed(QObject*)) );
00076 
00077   /*
00078   ** Return the current list count.
00079   **
00080   */
00081   return( count() );
00082 
00083 } // endlong DumontObjects::add( CommenceObject * object )
00084 
00085 long DumontObjects::remove( DumontObject * object )
00086 {
00087   return( count() );
00088 }
00089 
00090 DumontObject * DumontObjects::get( const long index )
00091 {
00092   if( index < count() )
00093   {
00094     return( m_objects.at(index) );
00095   }
00096 
00097   return( NULL );
00098 }
00099 
00100 DumontObject * DumontObjects::get( const QString & name )
00101 {
00102   for( int i=0; i<count(); i++ )
00103   {
00104     if( m_objects[i]-> DumontObject::name() == name )
00105     {
00106       return( m_objects.at(i) );
00107     }
00108   }
00109   return( NULL );
00110 }
00111 
00112 void DumontObjects::on_objectDestroyed( QObject * object )
00113 {
00114   m_objects.removeAll( (DumontObject*)object );
00115 }
00116 
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties




~ ~ ~ ~ ~ ~
Source Code without Comments is like a Cranberry Garland
without the berries. Comment your Code!
 
Commence Database User Support Group Forum
http://newsgroup.showoff-db.org/
~ ~ ~ ~ ~ ~
Author: Mark Petryk
Lorimark Solutions, LLC
mark@lorimarksolutions.com