diff options
author | Jacek Antonelli | 2008-08-15 23:44:50 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:50 -0500 |
commit | 89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch) | |
tree | bcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/llcommon/lllivefile.cpp | |
parent | Second Life viewer sources 1.13.3.2 (diff) | |
download | meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2 meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz |
Second Life viewer sources 1.14.0.0
Diffstat (limited to 'linden/indra/llcommon/lllivefile.cpp')
-rw-r--r-- | linden/indra/llcommon/lllivefile.cpp | 88 |
1 files changed, 78 insertions, 10 deletions
diff --git a/linden/indra/llcommon/lllivefile.cpp b/linden/indra/llcommon/lllivefile.cpp index 33e2014..d289671 100644 --- a/linden/indra/llcommon/lllivefile.cpp +++ b/linden/indra/llcommon/lllivefile.cpp | |||
@@ -27,24 +27,56 @@ | |||
27 | #include "linden_common.h" | 27 | #include "linden_common.h" |
28 | 28 | ||
29 | #include "lllivefile.h" | 29 | #include "lllivefile.h" |
30 | #include "llframetimer.h" | ||
31 | #include "lltimer.h" | ||
30 | 32 | ||
33 | class LLLiveFile::Impl | ||
34 | { | ||
35 | public: | ||
36 | Impl(const std::string &filename, const F32 refresh_period); | ||
37 | ~Impl(); | ||
38 | |||
39 | bool check(); | ||
40 | |||
41 | |||
42 | bool mForceCheck; | ||
43 | F32 mRefreshPeriod; | ||
44 | LLFrameTimer mRefreshTimer; | ||
31 | 45 | ||
32 | LLLiveFile::LLLiveFile(const std::string &filename, const F32 refresh_period) : | 46 | std::string mFilename; |
33 | mForceCheck(true), | 47 | time_t mLastModTime; |
34 | mRefreshPeriod(refresh_period), | 48 | bool mLastExists; |
35 | mFilename(filename), | 49 | |
36 | mLastModTime(0), | 50 | LLEventTimer* mEventTimer; |
37 | mLastExists(false) | 51 | }; |
52 | |||
53 | LLLiveFile::Impl::Impl(const std::string &filename, const F32 refresh_period) | ||
54 | : mForceCheck(true), | ||
55 | mRefreshPeriod(refresh_period), | ||
56 | mFilename(filename), | ||
57 | mLastModTime(0), | ||
58 | mLastExists(false), | ||
59 | mEventTimer(NULL) | ||
38 | { | 60 | { |
39 | } | 61 | } |
40 | 62 | ||
63 | LLLiveFile::Impl::~Impl() | ||
64 | { | ||
65 | delete mEventTimer; | ||
66 | } | ||
67 | |||
68 | LLLiveFile::LLLiveFile(const std::string &filename, const F32 refresh_period) | ||
69 | : impl(* new Impl(filename, refresh_period)) | ||
70 | { | ||
71 | } | ||
41 | 72 | ||
42 | LLLiveFile::~LLLiveFile() | 73 | LLLiveFile::~LLLiveFile() |
43 | { | 74 | { |
75 | delete &impl; | ||
44 | } | 76 | } |
45 | 77 | ||
46 | 78 | ||
47 | bool LLLiveFile::checkAndReload() | 79 | bool LLLiveFile::Impl::check() |
48 | { | 80 | { |
49 | if (!mForceCheck && mRefreshTimer.getElapsedTimeF32() < mRefreshPeriod) | 81 | if (!mForceCheck && mRefreshTimer.getElapsedTimeF32() < mRefreshPeriod) |
50 | { | 82 | { |
@@ -65,9 +97,8 @@ bool LLLiveFile::checkAndReload() | |||
65 | // broken somehow. Clear flags and return. | 97 | // broken somehow. Clear flags and return. |
66 | if (mLastExists) | 98 | if (mLastExists) |
67 | { | 99 | { |
68 | loadFile(); // Load the file, even though it's missing to allow it to clear state. | ||
69 | mLastExists = false; | 100 | mLastExists = false; |
70 | return true; | 101 | return true; // no longer existing is a change! |
71 | } | 102 | } |
72 | return false; | 103 | return false; |
73 | } | 104 | } |
@@ -87,7 +118,44 @@ bool LLLiveFile::checkAndReload() | |||
87 | mLastExists = true; | 118 | mLastExists = true; |
88 | mLastModTime = stat_data.st_mtime; | 119 | mLastModTime = stat_data.st_mtime; |
89 | 120 | ||
90 | loadFile(); | ||
91 | return true; | 121 | return true; |
92 | } | 122 | } |
93 | 123 | ||
124 | bool LLLiveFile::checkAndReload() | ||
125 | { | ||
126 | bool changed = impl.check(); | ||
127 | if (changed) | ||
128 | { | ||
129 | loadFile(); | ||
130 | } | ||
131 | return changed; | ||
132 | } | ||
133 | |||
134 | std::string LLLiveFile::filename() const | ||
135 | { | ||
136 | return impl.mFilename; | ||
137 | } | ||
138 | |||
139 | namespace | ||
140 | { | ||
141 | class LiveFileEventTimer : public LLEventTimer | ||
142 | { | ||
143 | public: | ||
144 | LiveFileEventTimer(LLLiveFile& f, F32 refresh) | ||
145 | : LLEventTimer(refresh), mLiveFile(f) | ||
146 | { } | ||
147 | |||
148 | void tick() | ||
149 | { mLiveFile.checkAndReload(); } | ||
150 | |||
151 | private: | ||
152 | LLLiveFile& mLiveFile; | ||
153 | }; | ||
154 | |||
155 | } | ||
156 | |||
157 | void LLLiveFile::addToEventTimer() | ||
158 | { | ||
159 | impl.mEventTimer = new LiveFileEventTimer(*this, impl.mRefreshPeriod); | ||
160 | } | ||
161 | |||