HoverRace  2.0
ElemHeap.h
Go to the documentation of this file.
1 
2 // ElemHeap.h
3 //
4 // Copyright (c) 2015 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
25 # ifdef MR_ENGINE
26 # define MR_DllDeclare __declspec( dllexport )
27 # else
28 # define MR_DllDeclare __declspec( dllimport )
29 # endif
30 #else
31 # define MR_DllDeclare
32 #endif
33 
34 namespace HoverRace {
35  namespace Model {
36  class FreeElement;
37  }
38  namespace Parcel {
39  class ObjStream;
40  }
41 }
42 
43 namespace HoverRace {
44 namespace Model {
45 
54 class ElemHeap
55 {
56 public:
57  ElemHeap() { }
58  ElemHeap(const ElemHeap&) = default;
59  ElemHeap(ElemHeap&&) = default;
60  ~ElemHeap() { }
61 
62  ElemHeap &operator=(const ElemHeap&) = default;
63  ElemHeap &operator=(ElemHeap&&) = default;
64 
65 private:
66  using elems_t = std::list<std::shared_ptr<FreeElement>>;
67 public:
68  using Handle = elems_t::const_iterator;
69 
70 public:
71  Handle Add(std::shared_ptr<FreeElement> elem)
72  {
73  elems.emplace_back(std::move(elem));
74  return --elems.cend();
75  }
76 
77 public:
78  void StreamIn(Parcel::ObjStream &pArchive);
79  void StreamOut(Parcel::ObjStream &pArchive) const;
80 
81 private:
83 };
84 
85 } // namespace Model
86 } // namespace HoverRace
87 
88 #undef MR_DllDeclare
~ElemHeap()
Definition: ElemHeap.h:60
elems_t::const_iterator Handle
Definition: ElemHeap.h:68
Base class for parcel serializers.
Definition: ObjStream.h:58
std::list< std::shared_ptr< FreeElement >> elems_t
Definition: ElemHeap.h:66
ElemHeap()
Definition: ElemHeap.h:57
elems_t elems
Definition: ElemHeap.h:82
A managed pile of FreeElement instances.
Definition: ElemHeap.h:54
Definition: Announcement.h:24
Handle Add(std::shared_ptr< FreeElement > elem)
Definition: ElemHeap.h:71