/[pcsx2_0.9.7]/trunk/3rdparty/wxWidgets/src/common/ipcbase.cpp
ViewVC logotype

Contents of /trunk/3rdparty/wxWidgets/src/common/ipcbase.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (show annotations) (download)
Tue Sep 7 03:24:11 2010 UTC (10 years, 3 months ago) by william
File size: 2326 byte(s)
committing r3113 initial commit again...
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/ipcbase.cpp
3 // Purpose: IPC base classes
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id: ipcbase.cpp 54615 2008-07-14 02:34:29Z VZ $
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #endif
21
22 #include "wx/ipcbase.h"
23
24 IMPLEMENT_CLASS(wxServerBase, wxObject)
25 IMPLEMENT_CLASS(wxClientBase, wxObject)
26 IMPLEMENT_CLASS(wxConnectionBase, wxObject)
27
28 wxConnectionBase::wxConnectionBase(wxChar *buffer, int bytes)
29 : m_connected(true),
30 m_buffer(buffer),
31 m_buffersize(bytes),
32 m_deletebufferwhendone(false)
33 {
34 if ( buffer == (wxChar *)NULL )
35 { // behave like next constructor
36 m_buffersize = 0;
37 m_deletebufferwhendone = true;
38 }
39 }
40
41 wxConnectionBase::wxConnectionBase()
42 : m_connected(true),
43 m_buffer(NULL),
44 m_buffersize(0),
45 m_deletebufferwhendone(true)
46 {
47 }
48
49 wxConnectionBase::wxConnectionBase(const wxConnectionBase& copy)
50 : wxObject(),
51 m_connected(copy.m_connected),
52 m_buffer(copy.m_buffer),
53 m_buffersize(copy.m_buffersize),
54 m_deletebufferwhendone(false)
55
56 {
57 // copy constructor would require ref-counted pointer to buffer
58 wxFAIL_MSG( _T("Copy constructor of wxConnectionBase not implemented") );
59 }
60
61
62 wxConnectionBase::~wxConnectionBase(void)
63 {
64 if ( m_deletebufferwhendone )
65 delete [] m_buffer;
66 }
67
68 wxChar *wxConnectionBase::GetBufferAtLeast( size_t bytes )
69 {
70 if ( m_buffersize >= bytes )
71 return m_buffer;
72 else
73 { // need to resize buffer
74 if ( m_deletebufferwhendone )
75 { // we're in charge of buffer, increase it
76 delete [] m_buffer;
77 // the argument specifies **byte size**, but m_buffer is of type
78 // wxChar. Under unicode: sizeof(wxChar) > 1, so the buffer size is
79 // bytes / sizeof(wxChar) rounded upwards.
80 m_buffer = new wxChar[(bytes + sizeof(wxChar) - 1) / sizeof(wxChar)];
81 m_buffersize = bytes;
82 return m_buffer;
83 } // user-supplied buffer, fail
84 else
85 return NULL;
86 }
87 }

  ViewVC Help
Powered by ViewVC 1.1.22