File: backgrounds.hh

package info (click to toggle)
performous 0.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 6,748 kB
  • ctags: 2,894
  • sloc: cpp: 14,729; sh: 275; objc: 245; makefile: 102; xml: 14
file content (47 lines) | stat: -rw-r--r-- 1,139 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once

#include "animvalue.hh"
#include "fs.hh"
#include "song.hh"
#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <set>
#include <vector>

/// songs class for songs screen
class Backgrounds: boost::noncopyable {
  public:
	/// constructor
	Backgrounds(): m_bgiter(0), m_dirty(false), m_loading(false)
	{
		reload();
	}
	~Backgrounds() {
		m_loading = false; // Terminate loading if currently in progress
		m_thread->join();
	}
	/// reloads backgrounds list
	void reload();
	/// array access
	std::string& operator[](std::size_t pos) { return m_bgs.at(pos); }
	/// number of backgrounds
	int size() const { return m_bgs.size(); };
	/// true if empty
	int empty() const { return m_bgs.empty(); };
	/// returns random background
	std::string getRandom();
	
  private:
	typedef std::vector<std::string> BGVector;
	BGVector m_bgs;
	int m_bgiter;
	void reload_internal();
	void reload_internal(fs::path const& p);
	volatile bool m_dirty;
	volatile bool m_loading;
	boost::scoped_ptr<boost::thread> m_thread;
	mutable boost::mutex m_mutex;
};