Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / apps / JAWS3 / jaws3 / FILE.cpp
blob90a0fd8706b4172e39f87a3530f5ad3850b0c9eb
1 #include "ace/config-all.h"
2 #include "ace/Guard_T.h"
3 #include "ace/Synch_Traits.h"
4 #include "ace/Thread_Mutex.h"
6 #ifndef JAWS_BUILD_DLL
7 #define JAWS_BUILD_DLL
8 #endif
10 #include "jaws3/FILE.h"
13 JAWS_FILE::JAWS_FILE ()
14 : map_ (0)
15 , can_map_ (0)
19 JAWS_FILE::~JAWS_FILE ()
21 delete this->map_;
22 this->map_ = 0;
25 ACE_Mem_Map *
26 JAWS_FILE::mem_map (int length,
27 int prot,
28 int share,
29 void *addr,
30 ACE_OFF_T offset,
31 LPSECURITY_ATTRIBUTES sa) const
33 if (this->can_map_ == 0)
34 return 0;
36 JAWS_FILE *mutable_this = (JAWS_FILE *) this;
37 return mutable_this->mem_map (length, prot, share, addr, offset, sa);
40 ACE_Mem_Map *
41 JAWS_FILE::mem_map (int length,
42 int prot,
43 int share,
44 void *addr,
45 ACE_OFF_T offset,
46 LPSECURITY_ATTRIBUTES sa)
48 if (this->can_map_ == 0)
49 return 0;
51 if (this->map_ == 0)
53 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, g, this->lock_, 0);
55 if (this->map_ == 0)
57 this->map_ = new ACE_Mem_Map;
58 if (this->map_ != 0)
60 int r = this->map_->map (this->get_handle (),
61 static_cast<size_t> (length),
62 prot,
63 share,
64 addr,
65 offset,
66 sa);
67 if (r < 0)
69 delete this->map_;
70 this->map_ = 0;
76 return this->map_;
80 ACE_Mem_Map *
81 JAWS_FILE::map () const
83 return this->map_;
86 void
87 JAWS_FILE::can_map (int flag)
89 this->can_map_ = (flag != 0);