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