]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/ipcbase.cpp
added debug/release DLL configurations so that VC++ chooses the right one when buildi...
[wxWidgets.git] / src / common / ipcbase.cpp
... / ...
CommitLineData
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
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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
29IMPLEMENT_CLASS(wxServerBase, wxObject)
30IMPLEMENT_CLASS(wxClientBase, wxObject)
31IMPLEMENT_CLASS(wxConnectionBase, wxObject)
32
33wxConnectionBase::wxConnectionBase(wxChar *buffer, int size)
34 : m_connected(true),
35 m_buffer(buffer),
36 m_buffersize(size),
37 m_deletebufferwhendone(false)
38{
39 if ( buffer == (wxChar *)NULL )
40 { // behave like next constructor
41 m_buffersize = 0;
42 m_deletebufferwhendone = true;
43 }
44}
45
46wxConnectionBase::wxConnectionBase()
47 : m_connected(true),
48 m_buffer(NULL),
49 m_buffersize(0),
50 m_deletebufferwhendone(true)
51{
52}
53
54wxConnectionBase::wxConnectionBase(wxConnectionBase& copy)
55 : wxObject(),
56 m_connected(copy.m_connected),
57 m_buffer(copy.m_buffer),
58 m_buffersize(copy.m_buffersize),
59 m_deletebufferwhendone(false)
60
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
81 if ( m_buffer )
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}
91