HoverRace  2.0
ProfileGallery.h
Go to the documentation of this file.
1 
2 // ProfileGallery.h
3 //
4 // Copyright (c) 2016 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 #include "../Util/OS.h"
25 #include "Profile.h"
26 
27 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
28 # ifdef MR_ENGINE
29 # define MR_DllDeclare __declspec( dllexport )
30 # else
31 # define MR_DllDeclare __declspec( dllimport )
32 # endif
33 #else
34 # define MR_DllDeclare
35 #endif
36 
37 namespace HoverRace {
38  namespace Player {
39  class AvatarGallery;
40  }
41 }
42 
43 namespace HoverRace {
44 namespace Player {
45 
51 {
52 public:
53  ProfileGallery(std::shared_ptr<AvatarGallery> avatarGallery,
54  const Util::OS::path_t &path = {});
55 
56 public:
57  void Reload();
58 
59 public:
60  bool IsEmpty() const { return profiles.empty(); }
61 
62 public:
63  std::shared_ptr<Profile> FindUid(const std::string &uid) const;
64  std::shared_ptr<Profile> FindUid(const boost::uuids::uuid &uid) const;
65  std::shared_ptr<Profile> FindName(const std::string &name) const;
66 
67 private:
68  using profiles_t = std::vector<std::shared_ptr<Profile>>;
69 public:
70  // STL-like iteration, so we can use range-for.
71  using iterator = profiles_t::iterator;
72  using const_iterator = profiles_t::const_iterator;
73  using value_type = profiles_t::value_type;
74  const_iterator begin() const { return profiles.begin(); }
75  iterator begin() { return profiles.begin(); }
76  const_iterator end() const { return profiles.end(); }
77  iterator end() { return profiles.end(); }
78 
79 private:
80  std::shared_ptr<AvatarGallery> avatarGallery;
83 };
84 
85 } // namespace Player
86 } // namespace HoverRace
87 
88 #undef MR_DllDeclare
boost::filesystem::path path_t
Definition: OS.h:57
Definition: Announcement.h:24