Initial Patch of Auction House bot rev. 135
[auctionmangos.git] / dep / ACE_wrappers / ace / SV_Shared_Memory.cpp
blob9db097ca2e857dcbfdc3bdfec822ddb6e7011784
1 // $Id: SV_Shared_Memory.cpp 80826 2008-03-04 14:51:23Z wotte $
3 #include "ace/SV_Shared_Memory.h"
4 #include "ace/Log_Msg.h"
6 #if !defined (__ACE_INLINE__)
7 #include "ace/SV_Shared_Memory.inl"
8 #endif /* __ACE_INLINE__ */
10 ACE_RCSID(ace, SV_Shared_Memory, "$Id: SV_Shared_Memory.cpp 80826 2008-03-04 14:51:23Z wotte $")
12 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
14 ACE_ALLOC_HOOK_DEFINE(ACE_SV_Shared_Memory)
16 void
17 ACE_SV_Shared_Memory::dump (void) const
19 #if defined (ACE_HAS_DUMP)
20 ACE_TRACE ("ACE_SV_Shared_Memory::dump");
21 #endif /* ACE_HAS_DUMP */
24 // Creates a shared memory segment of SIZE bytes and *does* attach to
25 // this segment.
27 int
28 ACE_SV_Shared_Memory::open_and_attach (key_t external_id,
29 size_t sz,
30 int create,
31 int perms,
32 void *virtual_addr,
33 int flags)
35 ACE_TRACE ("ACE_SV_Shared_Memory::open_and_attach");
36 if (this->open (external_id, sz, create, perms) == -1)
37 return -1;
38 else if (this->attach (virtual_addr, flags) == -1)
39 return -1;
40 else
41 return 0;
44 // Constructor interface to this->open_and_attach () member function.
46 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (key_t external_id,
47 size_t sz,
48 int create,
49 int perms,
50 void *virtual_addr,
51 int flags)
53 ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
54 if (this->open_and_attach (external_id, sz, create,
55 perms, virtual_addr, flags) == -1)
56 ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
57 ACE_TEXT ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory")));
60 // The "do nothing" constructor.
62 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (void)
63 : internal_id_ (0),
64 size_ (0),
65 segment_ptr_ (0)
67 ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
70 // Added this constructor to accept an internal id, the one generated
71 // when a server constructs with the key IPC_PRIVATE. The client can
72 // be passed ACE_SV_Shared_Memory::internal_id via a socket and call
73 // this construtor to attach the existing segment. This prevents
74 // having to hard-code a key in advance. Courtesy of Marvin Wolfthal
75 // (maw@fsg.com).
77 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (ACE_HANDLE int_id,
78 int flags)
79 : internal_id_ (int_id),
80 size_ (0)
82 ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
83 if (this->attach (0, flags) == -1)
84 ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
85 ACE_TEXT ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory")));
88 ACE_END_VERSIONED_NAMESPACE_DECL