private:
- wxClassInfo *m_before; // sm_first before loading this lib
- wxClassInfo *m_after; // ..and after.
+ const wxClassInfo *m_before; // sm_first before loading this lib
+ const wxClassInfo *m_after; // ..and after.
size_t m_linkcount; // Ref count of library link calls
size_t m_objcount; // ..and (pluggable) object instantiations.
#else // if wxUSE_OLD_HASH_TABLE
+typedef wxNode wxHashTable_Node;
+
class WXDLLIMPEXP_BASE wxHashTable : public wxObject
{
public:
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxT("mediaCtrl"));
- bool DoCreate(wxClassInfo* instance,
+ bool DoCreate(const wxClassInfo* instance,
wxWindow* parent, wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
{ return Load(wxURI(fileName), wxURI(proxy)); }
protected:
- static wxClassInfo* NextBackend();
+ static const wxClassInfo* NextBackend(wxClassInfo::const_iterator* it);
void OnMediaFinished(wxMediaEvent& evt);
virtual void DoMoveWindow(int x, int y, int w, int h);
#define wxUSE_EXTENDED_RTTI 0
#endif
+#define DECLARE_CLASS_INFO_ITERATORS() \
+ class WXDLLIMPEXP_BASE const_iterator \
+ { \
+ typedef wxHashTable_Node Node; \
+ public: \
+ typedef const wxClassInfo* value_type; \
+ typedef const value_type& const_reference; \
+ typedef const_iterator itor; \
+ typedef value_type* ptr_type; \
+ \
+ Node* m_node; \
+ wxHashTable* m_table; \
+ public: \
+ typedef const_reference reference_type; \
+ typedef ptr_type pointer_type; \
+ \
+ const_iterator(Node* node, wxHashTable* table) \
+ : m_node(node), m_table(table) { } \
+ const_iterator() : m_node(NULL), m_table(NULL) { } \
+ value_type operator*() const; \
+ itor& operator++(); \
+ const itor operator++(int); \
+ bool operator!=(const itor& it) const \
+ { return it.m_node != m_node; } \
+ bool operator==(const itor& it) const \
+ { return it.m_node == m_node; } \
+ }; \
+ \
+ static const_iterator begin_classinfo(); \
+ static const_iterator end_classinfo();
+
#if wxUSE_EXTENDED_RTTI
#include "wx/xti.h"
#else
class WXDLLIMPEXP_BASE wxClassInfo;
class WXDLLIMPEXP_BASE wxHashTable;
+class WXDLLIMPEXP_BASE wxObject;
+class WXDLLIMPEXP_BASE wxPluginLibrary;
class WXDLLIMPEXP_BASE wxObjectRefData;
+class WXDLLIMPEXP_BASE wxHashTable_Node;
// ----------------------------------------------------------------------------
// wxClassInfo
class WXDLLIMPEXP_BASE wxClassInfo
{
+ friend class WXDLLIMPEXP_BASE wxObject;
+ friend wxObject *wxCreateDynamicObject(const wxChar *name);
public:
wxClassInfo( const wxChar *className,
const wxClassInfo *baseInfo1,
( m_baseInfo2 && m_baseInfo2->IsKindOf(info) ) );
}
-public:
+ DECLARE_CLASS_INFO_ITERATORS()
+private:
const wxChar *m_className;
int m_objectSize;
wxObjectConstructorFn m_objectConstructor;
static wxClassInfo *sm_first;
wxClassInfo *m_next;
- // FIXME: this should be private (currently used directly by way too
- // many clients)
static wxHashTable *sm_classTable;
protected:
class WXDLLIMPEXP_BASE wxClassInfo;
class WXDLLIMPEXP_BASE wxDynamicClassInfo;
class WXDLLIMPEXP_BASE wxHashTable;
+class WXDLLIMPEXP_BASE wxHashTable_Node;
class WXDLLIMPEXP_BASE wxObjectRefData;
class WXDLLIMPEXP_BASE wxEvent;
class WXDLLIMPEXP_BASE wxEvtHandler;
{
friend class WXDLLIMPEXP_BASE wxPropertyInfo ;
friend class WXDLLIMPEXP_BASE wxHandlerInfo ;
+ friend wxObject *wxCreateDynamicObject(const wxChar *name);
public:
wxClassInfo(const wxClassInfo **_Parents,
const wxChar *_UnitName,
return false ;
}
+ DECLARE_CLASS_INFO_ITERATORS()
+
// if there is a callback registered with that class it will be called
// before this object will be written to disk, it can veto streaming out
// this object by returning false, if this class has not registered a
// puts all the properties of this class and its superclasses in the map, as long as there is not yet
// an entry with the same name (overriding mechanism)
void GetProperties( wxPropertyInfoMap &map ) const ;
-public:
+private:
const wxChar *m_className;
int m_objectSize;
wxObjectConstructorFn m_objectConstructor;
static wxClassInfo *sm_first;
wxClassInfo *m_next;
- // FIXME: this should be private (currently used directly by way too
- // many clients)
static wxHashTable *sm_classTable;
protected :
: m_linkcount(1)
, m_objcount(0)
{
- m_before = wxClassInfo::sm_first;
+ m_before = wxClassInfo::GetFirst();
Load( libname, flags );
- m_after = wxClassInfo::sm_first;
+ m_after = wxClassInfo::GetFirst();
if( m_handle != 0 )
{
void wxPluginLibrary::UpdateClasses()
{
- for (wxClassInfo *info = m_after; info != m_before; info = info->m_next)
+ for (const wxClassInfo *info = m_after; info != m_before; info = info->GetNext())
{
if( info->GetClassName() )
{
if (!ms_classes)
return;
- for(wxClassInfo *info = m_after; info != m_before; info = info->m_next)
+ for(const wxClassInfo *info = m_after; info != m_before; info = info->GetNext())
{
ms_classes->erase(ms_classes->find(info->GetClassName()));
}
wxASSERT_MSG( m_linkcount == 1,
_T("RegisterModules should only be called for the first load") );
- for ( wxClassInfo *info = m_after; info != m_before; info = info->m_next)
+ for ( const wxClassInfo *info = m_after; info != m_before; info = info->GetNext())
{
if( info->IsKindOf(CLASSINFO(wxModule)) )
{
}
else
{
- wxClassInfo::sm_classTable->BeginFind();
+ wxClassInfo::const_iterator it = wxClassInfo::begin_classinfo();
- wxClassInfo* classInfo;
+ const wxClassInfo* classInfo;
- while((classInfo = NextBackend()) != NULL)
+ while((classInfo = NextBackend(&it)) != NULL)
{
+ wxLogMessage( classInfo->GetClassName() );
if(!DoCreate(classInfo, parent, id,
pos, size, style, validator, name))
continue;
}
else
{
- wxClassInfo::sm_classTable->BeginFind();
+ wxClassInfo::const_iterator it = wxClassInfo::begin_classinfo();
- wxClassInfo* classInfo;
+ const wxClassInfo* classInfo;
- while((classInfo = NextBackend()) != NULL)
+ while((classInfo = NextBackend(&it)) != NULL)
{
if(!DoCreate(classInfo, parent, id,
pos, size, style, validator, name))
//
// Attempts to create the control from a backend
//---------------------------------------------------------------------------
-bool wxMediaCtrl::DoCreate(wxClassInfo* classInfo,
+bool wxMediaCtrl::DoCreate(const wxClassInfo* classInfo,
wxWindow* parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
// incompatible with the old 2.4 stable version - but since
// we're in 2.5+ only we don't need to worry about the new version
//---------------------------------------------------------------------------
-wxClassInfo* wxMediaCtrl::NextBackend()
+const wxClassInfo* wxMediaCtrl::NextBackend(wxClassInfo::const_iterator* it)
{
- wxHashTable::compatibility_iterator
- node = wxClassInfo::sm_classTable->Next();
- while (node)
+ for ( wxClassInfo::const_iterator end = wxClassInfo::end_classinfo();
+ *it != end; ++(*it) )
{
- wxClassInfo* classInfo = (wxClassInfo *)node->GetData();
+ const wxClassInfo* classInfo = **it;
if ( classInfo->IsKindOf(CLASSINFO(wxMediaBackend)) &&
classInfo != CLASSINFO(wxMediaBackend) )
{
return classInfo;
}
- node = wxClassInfo::sm_classTable->Next();
}
//
}
int n = 0;
- wxHashTable::compatibility_iterator node;
- wxClassInfo *info;
+ const wxClassInfo *info;
- wxClassInfo::sm_classTable->BeginFind();
- node = wxClassInfo::sm_classTable->Next();
- while (node)
+ for (wxClassInfo::const_iterator node = wxClassInfo::begin_classinfo(),
+ end = wxClassInfo::end_classinfo();
+ node != end; ++node)
{
- info = (wxClassInfo *)node->GetData();
+ info = *node;
if (info->GetClassName())
{
wxString msg(info->GetClassName());
wxLogMessage(msg);
}
- node = wxClassInfo::sm_classTable->Next();
n ++;
}
wxLogMessage(wxEmptyString);
// and register them.
void wxModule::RegisterModules()
{
- wxHashTable::compatibility_iterator node;
- wxClassInfo* classInfo;
-
- wxClassInfo::sm_classTable->BeginFind();
- node = wxClassInfo::sm_classTable->Next();
- while (node)
+ for (wxClassInfo::const_iterator it = wxClassInfo::begin_classinfo(),
+ end = wxClassInfo::end_classinfo();
+ it != end; ++it)
{
- classInfo = (wxClassInfo *)node->GetData();
+ const wxClassInfo* classInfo = *it;
+
if ( classInfo->IsKindOf(CLASSINFO(wxModule)) &&
- (classInfo != (& (wxModule::ms_classInfo))) )
+ (classInfo != (& (wxModule::ms_classInfo))) )
{
wxLogTrace(TRACE_MODULE, wxT("Registering module %s"),
classInfo->GetClassName());
wxModule* module = (wxModule *)classInfo->CreateObject();
- RegisterModule(module);
+ wxModule::RegisterModule(module);
}
- node = wxClassInfo::sm_classTable->Next();
}
}
}
}
+// iterator interface
+wxClassInfo::const_iterator::value_type
+wxClassInfo::const_iterator::operator*() const
+{
+ return (wxClassInfo*)m_node->GetData();
+}
+
+wxClassInfo::const_iterator& wxClassInfo::const_iterator::operator++()
+{
+ m_node = m_table->Next();
+ return *this;
+}
+
+const wxClassInfo::const_iterator wxClassInfo::const_iterator::operator++(int)
+{
+ wxClassInfo::const_iterator tmp = *this;
+ m_node = m_table->Next();
+ return tmp;
+}
+
+wxClassInfo::const_iterator wxClassInfo::begin_classinfo()
+{
+ sm_classTable->BeginFind();
+
+ return const_iterator(sm_classTable->Next(), sm_classTable);
+}
+
+wxClassInfo::const_iterator wxClassInfo::end_classinfo()
+{
+ return const_iterator(NULL, NULL);
+}
// ----------------------------------------------------------------------------
// wxObjectRefData