Also use Objects as part of an operation but as a result don't generate Any operation...
[ACE_TAO.git] / ACE / ace / SV_Shared_Memory.cpp
blobef65d4976c98a1b91f9fc066e32a074ce095d9fc
1 #include "ace/SV_Shared_Memory.h"
2 #include "ace/Log_Category.h"
3 #if defined (ACE_HAS_ALLOC_HOOKS)
4 # include "ace/Malloc_Base.h"
5 #endif /* ACE_HAS_ALLOC_HOOKS */
7 #if !defined (__ACE_INLINE__)
8 #include "ace/SV_Shared_Memory.inl"
9 #endif /* __ACE_INLINE__ */
13 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
15 ACE_ALLOC_HOOK_DEFINE(ACE_SV_Shared_Memory)
17 void
18 ACE_SV_Shared_Memory::dump (void) const
20 #if defined (ACE_HAS_DUMP)
21 ACE_TRACE ("ACE_SV_Shared_Memory::dump");
22 #endif /* ACE_HAS_DUMP */
25 // Creates a shared memory segment of SIZE bytes and *does* attach to
26 // this segment.
28 int
29 ACE_SV_Shared_Memory::open_and_attach (key_t external_id,
30 size_t sz,
31 int create,
32 int perms,
33 void *virtual_addr,
34 int flags)
36 ACE_TRACE ("ACE_SV_Shared_Memory::open_and_attach");
37 if (this->open (external_id, sz, create, perms) == -1)
38 return -1;
39 else if (this->attach (virtual_addr, flags) == -1)
40 return -1;
41 else
42 return 0;
45 // Constructor interface to this->open_and_attach () member function.
47 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (key_t external_id,
48 size_t sz,
49 int create,
50 int perms,
51 void *virtual_addr,
52 int flags)
54 ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
55 if (this->open_and_attach (external_id, sz, create,
56 perms, virtual_addr, flags) == -1)
57 ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
58 ACE_TEXT ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory")));
61 // The "do nothing" constructor.
63 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (void)
64 : internal_id_ (0),
65 size_ (0),
66 segment_ptr_ (0)
68 ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
71 // Added this constructor to accept an internal id, the one generated
72 // when a server constructs with the key IPC_PRIVATE. The client can
73 // be passed ACE_SV_Shared_Memory::internal_id via a socket and call
74 // this construtor to attach the existing segment. This prevents
75 // having to hard-code a key in advance. Courtesy of Marvin Wolfthal
76 // (maw@fsg.com).
78 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (ACE_HANDLE int_id,
79 int flags)
80 : internal_id_ (int_id),
81 size_ (0)
83 ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
84 if (this->attach (0, flags) == -1)
85 ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
86 ACE_TEXT ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory")));
89 ACE_END_VERSIONED_NAMESPACE_DECL