PageRenderTime 308ms CodeModel.GetById 120ms app.highlight 6ms RepoModel.GetById 176ms app.codeStats 0ms

/indra/newview/lldaycyclemanager.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 84 lines | 37 code | 15 blank | 32 comment | 0 complexity | 2d32a4db0168100743b234cf15cc79f1 MD5 | raw file
 1/**
 2 * @file lldaycyclemanager.h
 3 * @brief Implementation for the LLDayCycleManager class.
 4 *
 5 * $LicenseInfo:firstyear=2011&license=viewerlgpl$
 6 * Second Life Viewer Source Code
 7 * Copyright (C) 2011, Linden Research, Inc.
 8 * 
 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 * 
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 * 
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 * 
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24 * $/LicenseInfo$
25 */
26
27#ifndef LL_LLDAYCYCLEMANAGER_H
28#define LL_LLDAYCYCLEMANAGER_H
29
30#include <map>
31#include <string>
32
33#include "llwldaycycle.h"
34#include "llwlparammanager.h"
35
36/**
37 * WindLight day cycles manager class
38 *
39 * Provides interface for accessing, loading and saving day cycles.
40 */
41class LLDayCycleManager : public LLSingleton<LLDayCycleManager>
42{
43	LOG_CLASS(LLDayCycleManager);
44
45public:
46	typedef std::list<std::string> preset_name_list_t;
47
48	typedef std::map<std::string, LLWLDayCycle> dc_map_t;
49	typedef boost::signals2::signal<void()> modify_signal_t;
50
51	void getPresetNames(preset_name_list_t& names) const;
52	void getPresetNames(preset_name_list_t& user, preset_name_list_t& sys) const;
53	void getUserPresetNames(preset_name_list_t& user) const;
54
55	bool getPreset(const std::string name, LLWLDayCycle& day_cycle) const;
56	bool getPreset(const std::string name, LLSD& day_cycle) const;
57	bool presetExists(const std::string name) const;
58	bool isSystemPreset(const std::string& name) const;
59	bool savePreset(const std::string& name, const LLSD& data);
60	bool deletePreset(const std::string& name);
61
62	/// @return true if there is a day cycle that refers to the sky preset.
63	bool isSkyPresetReferenced(const std::string& preset_name) const;
64
65	/// Emitted when a preset gets added or deleted.
66	boost::signals2::connection setModifyCallback(const modify_signal_t::slot_type& cb);
67
68private:
69	friend class LLSingleton<LLDayCycleManager>;
70	/*virtual*/ void initSingleton();
71
72	void loadAllPresets();
73	void loadPresets(const std::string& dir);
74	bool loadPreset(const std::string& path);
75	bool addPreset(const std::string& name, const LLSD& data);
76
77	static std::string getSysDir();
78	static std::string getUserDir();
79
80	dc_map_t mDayCycleMap;
81	modify_signal_t mModifySignal;
82};
83
84#endif // LL_LLDAYCYCLEMANAGER_H