SDXFrameWork  0.13
SDXFrameWork
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Loading.h
1 //Copyright © 2014 SDXFramework
2 //[License]GNU Affero General Public License, version 3
3 //[Contact]http://sourceforge.jp/projects/dxframework/
4 #pragma once
5 
6 #include <Multimedia/SDX.h>
7 
8 namespace SDX
9 {
16  class Loading
17  {
18  friend class Image;
19  friend class ImagePack;
20  friend class Font;
21  friend class MixFont;
22  friend class Sound;
23  friend class Music;
24  friend class Movie;
25  private:
26  Loading(void) = default;
27  ~Loading(void) = default;
28  //void operator =(const Loading& src){}
29  //Loading(const Loading& src){}
30 
31  static bool isLoading;
32  static int loadingCount;
33  static int succesCount;
34  static std::mutex mtx;
35 
36  static std::vector<std::function<void(void)>> funcS;
37 
38  public:
39 
41  static void Start()
42  {
43  //Windowsのみ有効
44 #ifndef __WINDOWS__
45  return;
46 #endif
47  loadingCount = 0;
48  succesCount = 0;
49  isLoading = true;
50  }
51 
53  static void End()
54  {
55  if ( !isLoading )
56  {
57  return;
58  }
59 
60  isLoading = false;
61 
62  std::thread
63  (
64  [&]
65  {
66  for (auto it : funcS)
67  {
68  it();
69  ++succesCount;
70  }
71  funcS.clear();
72  }
73  ).detach();
74  }
75 
77  static int GetLoadingCount()
78  {
79  return loadingCount;
80  }
81 
83  static int GetSuccesCount()
84  {
85  std::lock_guard<std::mutex> lock(mtx);
86  return succesCount;
87  }
88 
90  static bool IsLoading()
91  {
92  return isLoading;
93  }
94 
96  static void AddLoading(std::function<void(void)> &&読み込み関数)
97  {
98  std::lock_guard<std::mutex> lock(mtx);
99  funcS.push_back(読み込み関数);
100  ++loadingCount;
101  }
102  };
103 }
static void Start()
非同期読み込みするResorceを登録開始.
Definition: Loading.h:41
static void End()
非同期読み込みするResorceの読込開始.
Definition: Loading.h:53
効果音用音声を表すクラス.
Definition: Sound.h:13
TrueTypeFontとBMPFontをまとめて扱うクラス.
Definition: Font.h:25
static int GetSuccesCount()
読み込んだリソース数を取得.
Definition: Loading.h:83
static int GetLoadingCount()
読み込み中と読み込んだリソース数を取得.
Definition: Loading.h:77
static bool IsLoading()
非同期読み込み登録中かどうか.
Definition: Loading.h:90
画像データを表すクラス.
Definition: Image.h:17
static void AddLoading(std::function< void(void)> &&読み込み関数)
非同期読み込み処理に追加.
Definition: Loading.h:96
BGM用音声を表すクラス.
Definition: Music.h:15
リソースの非同期読み込み支援関数.
Definition: Loading.h:16
複数のImageをまとめるクラス.
Definition: ImagePack.h:17
動画を表すクラス[未実装].
Definition: Movie.h:13