// process (i.e. does it result from our own attempt to establish the
// connection)?
bool IsOwnEvent() const { return m_id != 0; }
+
+ // implement the base class pure virtual
+ virtual wxEvent *Clone() const { return new wxDialUpEvent(*this); }
};
// the type of dialup event handler function
// exists only for optimization purposes.
bool IsCommandEvent() const { return m_isCommandEvent; }
- // specialized clone function since it is done a lot
- virtual wxEvent *Clone() const { return new wxEvent(*this); }
+ // this function is used to create a copy of the event polymorphically and
+ // all derived classes must implement it because otherwise wxPostEvent()
+ // for them wouldn't work (it needs to do a copy of the event)
+ virtual wxEvent *Clone() const = 0;
public:
wxObject* m_eventObject;
void SetAlignment(wxLayoutAlignment align) { m_alignment = align; }
wxLayoutAlignment GetAlignment() const { return m_alignment; }
+ virtual wxEvent *Clone() const { return new wxQueryLayoutInfoEvent(*this); }
+
protected:
int m_flags;
int m_requestedLength;
m_flags = 0;
m_id = id;
}
-// Read by the app
- inline void SetFlags(int flags) { m_flags = flags; }
- inline int GetFlags() const { return m_flags; }
-// Set by the app
- inline void SetRect(const wxRect& rect) { m_rect = rect; }
- inline wxRect GetRect() const { return m_rect; }
+ // Read by the app
+ void SetFlags(int flags) { m_flags = flags; }
+ int GetFlags() const { return m_flags; }
+
+ // Set by the app
+ void SetRect(const wxRect& rect) { m_rect = rect; }
+ wxRect GetRect() const { return m_rect; }
+
+ virtual wxEvent *Clone() const { return new wxCalculateLayoutEvent(*this); }
+
protected:
int m_flags;
wxRect m_rect;
virtual ~wxObject(void);
virtual wxClassInfo *GetClassInfo(void) const { return &sm_classwxObject; }
- wxObject *Clone(void) const;
- virtual void CopyObject(wxObject& object_dest) const;
bool IsKindOf(wxClassInfo *info) const;
// the exit code
int GetExitCode() { return m_exitcode; }
+ // implement the base class pure virtual
+ virtual wxEvent *Clone() const { return new wxProcessEvent(*this); }
+
public:
- int m_pid, m_exitcode;
+ int m_pid,
+ m_exitcode;
DECLARE_DYNAMIC_CLASS(wxProcessEvent)
};
void SetAddress(GAddress *address);
const wxSockAddress& operator =(const wxSockAddress& addr);
- void CopyObject(wxObject& dest) const;
+ // we need to be able to create copies of the addresses polymorphically (i.e.
+ // wihtout knowing the exact address class)
+ virtual wxSockAddress *Clone() const = 0;
protected:
GAddress *m_address;
wxString Hostname();
unsigned short Service();
- inline int Type() { return wxSockAddress::IPV4; }
+ virtual int Type() { return wxSockAddress::IPV4; }
+ virtual wxSockAddress *Clone() const { return new wxIPV4address(*this); }
};
#ifdef ENABLE_IPV6
wxString Hostname() const;
unsigned short Service() const;
- inline int Type() { return wxSockAddress::IPV6; }
+ virtual int Type() { return wxSockAddress::IPV6; }
+ virtual wxSockAddress *Clone() const { return new wxIPV6address(*this); }
};
#endif
void Filename(const wxString& name);
wxString Filename();
- inline int Type() { return wxSockAddress::UNIX; }
+ virtual int Type() { return wxSockAddress::UNIX; }
+ virtual wxSockAddress *Clone() const { return new wxUNIXaddress(*this); }
};
#endif
// __UNIX__
// accessors
int GetInterval() const { return m_interval; }
+ // implement the base class pure virtual
+ virtual wxEvent *Clone() const { return new wxTimerEvent(*this); }
+
private:
int m_interval;
if ( !m_pendingEvents )
m_pendingEvents = new wxList;
- wxEvent *event2 = (wxEvent *)event.Clone();
+ wxEvent *event2 = event.Clone();
m_pendingEvents->Append(event2);
{
if (m_addr) {
delete m_addr;
- m_addr = NULL;
Close();
}
- m_addr = (wxSockAddress *) addr.Clone();
+ m_addr = addr.Clone();
+
return TRUE;
}
return FALSE;
}
-wxObject *wxObject::Clone() const
-{
- wxObject *object = GetClassInfo()->CreateObject();
- CopyObject(*object);
- return object;
-}
-
-#ifdef __WXDEBUG__
-void wxObject::CopyObject(wxObject& object_dest) const
-#else // !Debug
-void wxObject::CopyObject(wxObject& WXUNUSED(object_dest)) const
-#endif // Debug/!Debug
-{
- wxASSERT(object_dest.GetClassInfo()->IsKindOf(GetClassInfo()));
-}
-
#if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT)
void wxObject::Dump(wxSTD ostream& str)
{
return *this;
}
-void wxSockAddress::CopyObject(wxObject& dest) const
-{
- wxSockAddress *addr = (wxSockAddress *)&dest;
-
- wxObject::CopyObject(dest);
- addr->SetAddress(GetAddress());
-}
-
void wxSockAddress::Clear()
-{
+{
GAddress_destroy(m_address);
m_address = GAddress_new();
}
bool wxIPV4address::Hostname(const wxString& name)
{
// Some people are sometimes fool.
- if (name == wxT(""))
+ if (name == wxT(""))
{
wxLogWarning( _("Trying to solve a NULL hostname: giving up") );
return FALSE;
unsigned short wxIPV4address::Service()
{
- return GAddress_INET_GetPort(m_address);
+ return GAddress_INET_GetPort(m_address);
}
#if 0
unsigned short wxIPV6address::Service()
{
- return GAddress_INET_GetPort(m_address);
+ return GAddress_INET_GetPort(m_address);
}
#endif
#endif
-#endif
+#endif
// wxUSE_SOCKETS