]> git.saurik.com Git - wxWidgets.git/blame - src/common/ipcbase.cpp
Cleanup
[wxWidgets.git] / src / common / ipcbase.cpp
CommitLineData
c801d85f
KB
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$
55d99c7a
JS
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
14f355c2 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
c801d85f
KB
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
c801d85f
KB
29IMPLEMENT_CLASS(wxServerBase, wxObject)
30IMPLEMENT_CLASS(wxClientBase, wxObject)
31IMPLEMENT_CLASS(wxConnectionBase, wxObject)
c801d85f 32
44379ce6 33wxConnectionBase::wxConnectionBase(wxChar *buffer, int size)
b7282ad2
DW
34 : m_connected(TRUE),
35 m_buffer(buffer),
bbcd408a 36 m_buffersize(size),
b7282ad2 37 m_deletebufferwhendone(FALSE)
44379ce6
JS
38{
39 if ( buffer == (wxChar *)NULL )
40 { // behave like next constructor
41 m_buffersize = 0;
b7282ad2 42 m_deletebufferwhendone = TRUE;
44379ce6
JS
43 }
44}
45
46wxConnectionBase::wxConnectionBase()
b7282ad2 47 : m_connected(TRUE),
bbcd408a
JS
48 m_buffer(NULL),
49 m_buffersize(0),
b7282ad2 50 m_deletebufferwhendone(TRUE)
44379ce6
JS
51{
52}
53
54wxConnectionBase::wxConnectionBase(wxConnectionBase& copy)
bbcd408a
JS
55 : m_connected(copy.m_connected),
56 m_buffer(copy.m_buffer),
57 m_buffersize(copy.m_buffersize),
b7282ad2 58 m_deletebufferwhendone(FALSE)
bbcd408a 59
44379ce6
JS
60{
61 // copy constructor would require ref-counted pointer to buffer
62 wxFAIL_MSG( _T("Copy constructor of wxConnectionBase not implemented") );
63}
64
65
66wxConnectionBase::~wxConnectionBase(void)
67{
68 if ( m_deletebufferwhendone && m_buffer )
69 delete m_buffer;
70}
71
72wxChar *wxConnectionBase::GetBufferAtLeast( size_t bytes )
73{
74 if ( m_buffersize >= bytes )
75 return m_buffer;
76 else
77 { // need to resize buffer
78 if ( m_deletebufferwhendone )
79 { // we're in charge of buffer, increase it
01d0d0e5 80 if ( m_buffer )
44379ce6
JS
81 delete m_buffer;
82 m_buffer = new wxChar[bytes];
83 m_buffersize = bytes;
84 return m_buffer;
85 } // user-supplied buffer, fail
86 else
87 return NULL;
88 }
89}
c801d85f 90