]>
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 and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
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 size
)
34 : m_buffer(buffer
), m_buffersize(size
),
35 m_deletebufferwhendone(false), m_connected(true)
37 if ( buffer
== (wxChar
*)NULL
)
38 { // behave like next constructor
40 m_deletebufferwhendone
= true;
44 wxConnectionBase::wxConnectionBase()
45 : m_buffersize(0), m_buffer(NULL
), m_deletebufferwhendone(true),
50 wxConnectionBase::wxConnectionBase(wxConnectionBase
& copy
)
51 : m_buffer(copy
.m_buffer
), m_buffersize(copy
.m_buffersize
),
52 m_deletebufferwhendone(false), m_connected(copy
.m_connected
)
54 // copy constructor would require ref-counted pointer to buffer
55 wxFAIL_MSG( _T("Copy constructor of wxConnectionBase not implemented") );
59 wxConnectionBase::~wxConnectionBase(void)
61 if ( m_deletebufferwhendone
&& m_buffer
)
65 wxChar
*wxConnectionBase::GetBufferAtLeast( size_t bytes
)
67 if ( m_buffersize
>= bytes
)
70 { // need to resize buffer
71 if ( m_deletebufferwhendone
)
72 { // we're in charge of buffer, increase it
75 m_buffer
= new wxChar
[bytes
];
78 } // user-supplied buffer, fail