]>
git.saurik.com Git - wxWidgets.git/blob - src/common/ipcbase.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/ipcbase.cpp
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"
22 #include "wx/ipcbase.h"
24 IMPLEMENT_CLASS(wxServerBase
, wxObject
)
25 IMPLEMENT_CLASS(wxClientBase
, wxObject
)
26 IMPLEMENT_CLASS(wxConnectionBase
, wxObject
)
28 wxConnectionBase::wxConnectionBase(wxChar
*buffer
, int bytes
)
32 m_deletebufferwhendone(false)
34 if ( buffer
== (wxChar
*)NULL
)
35 { // behave like next constructor
37 m_deletebufferwhendone
= true;
41 wxConnectionBase::wxConnectionBase()
45 m_deletebufferwhendone(true)
49 wxConnectionBase::wxConnectionBase(const wxConnectionBase
& copy
)
51 m_connected(copy
.m_connected
),
52 m_buffer(copy
.m_buffer
),
53 m_buffersize(copy
.m_buffersize
),
54 m_deletebufferwhendone(false)
57 // copy constructor would require ref-counted pointer to buffer
58 wxFAIL_MSG( _T("Copy constructor of wxConnectionBase not implemented") );
62 wxConnectionBase::~wxConnectionBase(void)
64 if ( m_deletebufferwhendone
&& m_buffer
)
68 wxChar
*wxConnectionBase::GetBufferAtLeast( size_t bytes
)
70 if ( m_buffersize
>= bytes
)
73 { // need to resize buffer
74 if ( m_deletebufferwhendone
)
75 { // we're in charge of buffer, increase it
78 // the argument specifies **byte size**, but m_buffer is of type
79 // wxChar. Under unicode: sizeof(wxChar) > 1, so the buffer size is
80 // bytes / sizeof(wxChar) rounded upwards.
81 m_buffer
= new wxChar
[(bytes
+ sizeof(wxChar
) - 1) / sizeof(wxChar
)];
84 } // user-supplied buffer, fail