summaryrefslogtreecommitdiff
path: root/indra/llcommon/lllivefile.h
blob: a71844e5a9ba9b40f2a4e08660f769c92a52930f (plain)
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
/** 
 * @file lllivefile.h
 * @brief Automatically reloads a file whenever it changes or is removed.
 *
 * Copyright (c) 2006-$CurrentYear$, Linden Research, Inc.
 * $License$
 */

#ifndef LL_LLLIVEFILE_H
#define LL_LLLIVEFILE_H


class LLLiveFile
{
public:
	LLLiveFile(const std::string &filename, const F32 refresh_period = 5.f);
	virtual ~LLLiveFile();

	bool checkAndReload();
		// Returns true if the file changed in any way
		// Call this before using anything that was read & cached from the file

	std::string filename() const;

	void addToEventTimer();
		// Normally, just calling checkAndReload() is enough.  In some cases
		// though, you may need to let the live file periodically check itself.

protected:
	virtual void loadFile() = 0; // Implement this to load your file if it changed

private:
	class Impl;
	Impl& impl;
};

#endif //LL_LLLIVEFILE_H