MCPcopy Create free account
hub / github.com/Icinga/icinga2 / UpdateRegion

Method UpdateRegion

lib/icinga/timeperiod.cpp:222–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220}
221
222void TimePeriod::UpdateRegion(double begin, double end, bool clearExisting)
223{
224 if (clearExisting) {
225 ObjectLock olock(this);
226 SetSegments(new Array());
227 } else {
228 if (begin < GetValidEnd())
229 begin = GetValidEnd();
230
231 if (end < GetValidEnd())
232 return;
233 }
234
235 Array::Ptr segments = GetUpdate()->Invoke({ this, begin, end });
236
237 {
238 ObjectLock olock(this);
239 RemoveSegment(begin, end);
240
241 if (segments) {
242 ObjectLock dlock(segments);
243 for (Dictionary::Ptr segment : segments) {
244 AddSegment(segment);
245 }
246 }
247 }
248
249 bool preferInclude = GetPreferIncludes();
250
251 /* First handle the non preferred timeranges */
252 Array::Ptr timeranges = preferInclude ? GetExcludes() : GetIncludes();
253
254 if (timeranges) {
255 ObjectLock olock(timeranges);
256 for (String name : timeranges) {
257 const TimePeriod::Ptr timeperiod = TimePeriod::GetByName(name);
258
259 if (timeperiod)
260 Merge(timeperiod, !preferInclude);
261 }
262 }
263
264 /* Preferred timeranges must be handled at the end */
265 timeranges = preferInclude ? GetIncludes() : GetExcludes();
266
267 if (timeranges) {
268 ObjectLock olock(timeranges);
269 for (String name : timeranges) {
270 const TimePeriod::Ptr timeperiod = TimePeriod::GetByName(name);
271
272 if (timeperiod)
273 Merge(timeperiod, preferInclude);
274 }
275 }
276}
277
278bool TimePeriod::GetIsInside() const
279{

Callers 4

UpdateTimerHandlerMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
BeginTimePeriodMethod · 0.80
EndTimePeriodMethod · 0.80

Calls 1

InvokeMethod · 0.45

Tested by

no test coverage detected