]> git.saurik.com Git - wxWidgets.git/blob - src/common/ipcbase.cpp
Added some const qualifiers.
[wxWidgets.git] / src / common / ipcbase.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: ipcbase.cpp
3 // Purpose: IPC base classes
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "ipcbase.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/defs.h"
25 #endif
26
27 #include "wx/ipcbase.h"
28
29 IMPLEMENT_CLASS(wxServerBase, wxObject)
30 IMPLEMENT_CLASS(wxClientBase, wxObject)
31 IMPLEMENT_CLASS(wxConnectionBase, wxObject)
32
33 wxConnectionBase::wxConnectionBase(wxChar *buffer, int size)
34 : m_buffer(buffer), m_buffersize(size),
35 m_deletebufferwhendone(false), m_connected(true)
36 {
37 if ( buffer == (wxChar *)NULL )
38 { // behave like next constructor
39 m_buffersize = 0;
40 m_deletebufferwhendone = true;
41 }
42 }
43
44 wxConnectionBase::wxConnectionBase()
45 : m_buffersize(0), m_buffer(NULL), m_deletebufferwhendone(true),
46 m_connected(true)
47 {
48 }
49
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)
53 {
54 // copy constructor would require ref-counted pointer to buffer
55 wxFAIL_MSG( _T("Copy constructor of wxConnectionBase not implemented") );
56 }
57
58
59 wxConnectionBase::~wxConnectionBase(void)
60 {
61 if ( m_deletebufferwhendone && m_buffer )
62 delete m_buffer;
63 }
64
65 wxChar *wxConnectionBase::GetBufferAtLeast( size_t bytes )
66 {
67 if ( m_buffersize >= bytes )
68 return m_buffer;
69 else
70 { // need to resize buffer
71 if ( m_deletebufferwhendone )
72 { // we're in charge of buffer, increase it
73 if ( !m_buffer )
74 delete m_buffer;
75 m_buffer = new wxChar[bytes];
76 m_buffersize = bytes;
77 return m_buffer;
78 } // user-supplied buffer, fail
79 else
80 return NULL;
81 }
82 }
83