]>
git.saurik.com Git - wxWidgets.git/blob - src/common/ipcbase.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: IPC base classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
23 #include "wx/ipcbase.h"
25 IMPLEMENT_CLASS(wxServerBase
, wxObject
)
26 IMPLEMENT_CLASS(wxClientBase
, wxObject
)
27 IMPLEMENT_CLASS(wxConnectionBase
, wxObject
)
29 wxConnectionBase::wxConnectionBase(wxChar
*buffer
, int bytes
)
33 m_deletebufferwhendone(false)
35 if ( buffer
== (wxChar
*)NULL
)
36 { // behave like next constructor
38 m_deletebufferwhendone
= true;
42 wxConnectionBase::wxConnectionBase()
46 m_deletebufferwhendone(true)
50 wxConnectionBase::wxConnectionBase(const wxConnectionBase
& copy
)
52 m_connected(copy
.m_connected
),
53 m_buffer(copy
.m_buffer
),
54 m_buffersize(copy
.m_buffersize
),
55 m_deletebufferwhendone(false)
58 // copy constructor would require ref-counted pointer to buffer
59 wxFAIL_MSG( _T("Copy constructor of wxConnectionBase not implemented") );
63 wxConnectionBase::~wxConnectionBase(void)
65 if ( m_deletebufferwhendone
&& m_buffer
)
69 wxChar
*wxConnectionBase::GetBufferAtLeast( size_t bytes
)
71 if ( m_buffersize
>= bytes
)
74 { // need to resize buffer
75 if ( m_deletebufferwhendone
)
76 { // we're in charge of buffer, increase it
79 // the argument specifies **byte size**, but m_buffer is of type
80 // wxChar. Under unicode: sizeof(wxChar) > 1, so the buffer size is
81 // bytes / sizeof(wxChar) rounded upwards.
82 m_buffer
= new wxChar
[(bytes
+ sizeof(wxChar
) - 1) / sizeof(wxChar
)];
85 } // user-supplied buffer, fail