]>
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "ipcbase.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
27 #include "wx/ipcbase.h"
29 IMPLEMENT_CLASS(wxServerBase
, wxObject
)
30 IMPLEMENT_CLASS(wxClientBase
, wxObject
)
31 IMPLEMENT_CLASS(wxConnectionBase
, wxObject
)
33 wxConnectionBase::wxConnectionBase(wxChar
*buffer
, int bytes
)
37 m_deletebufferwhendone(false)
39 if ( buffer
== (wxChar
*)NULL
)
40 { // behave like next constructor
42 m_deletebufferwhendone
= true;
46 wxConnectionBase::wxConnectionBase()
50 m_deletebufferwhendone(true)
54 wxConnectionBase::wxConnectionBase(wxConnectionBase
& copy
)
56 m_connected(copy
.m_connected
),
57 m_buffer(copy
.m_buffer
),
58 m_buffersize(copy
.m_buffersize
),
59 m_deletebufferwhendone(false)
62 // copy constructor would require ref-counted pointer to buffer
63 wxFAIL_MSG( _T("Copy constructor of wxConnectionBase not implemented") );
67 wxConnectionBase::~wxConnectionBase(void)
69 if ( m_deletebufferwhendone
&& m_buffer
)
73 wxChar
*wxConnectionBase::GetBufferAtLeast( size_t bytes
)
75 if ( m_buffersize
>= bytes
)
78 { // need to resize buffer
79 if ( m_deletebufferwhendone
)
80 { // we're in charge of buffer, increase it
83 // the argument specifies **byte size**, but m_buffer is of type
84 // wxChar. Under unicode: sizeof(wxChar) > 1, so the buffer size is
85 // bytes / sizeof(wxChar) rounded upwards.
86 m_buffer
= new wxChar
[(bytes
+ sizeof(wxChar
) - 1) / sizeof(wxChar
)];
89 } // user-supplied buffer, fail