mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
Implement TimePeriod::RemoveSegment().
This commit is contained in:
parent
442a2dbc7d
commit
d99671ba0e
@ -70,6 +70,9 @@
|
|||||||
<ClCompile Include="icinga-type.cpp">
|
<ClCompile Include="icinga-type.cpp">
|
||||||
<Filter>Quelldateien</Filter>
|
<Filter>Quelldateien</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="timeperiod.cpp">
|
||||||
|
<Filter>Quelldateien</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="i2-icinga.h">
|
<ClInclude Include="i2-icinga.h">
|
||||||
@ -126,6 +129,9 @@
|
|||||||
<ClInclude Include="usergroup.h">
|
<ClInclude Include="usergroup.h">
|
||||||
<Filter>Headerdateien</Filter>
|
<Filter>Headerdateien</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="timeperiod.h">
|
||||||
|
<Filter>Headerdateien</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="Headerdateien">
|
<Filter Include="Headerdateien">
|
||||||
|
@ -119,12 +119,32 @@ void TimePeriod::RemoveSegment(double begin, double end)
|
|||||||
if (!segments)
|
if (!segments)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Array::Ptr newSegments = boost::make_shared<Array>();
|
||||||
|
|
||||||
/* Try to split or adjust an existing segment. */
|
/* Try to split or adjust an existing segment. */
|
||||||
ObjectLock dlock(segments);
|
ObjectLock dlock(segments);
|
||||||
BOOST_FOREACH(const Dictionary::Ptr& segment, segments) {
|
BOOST_FOREACH(const Dictionary::Ptr& segment, segments) {
|
||||||
BOOST_THROW_EXCEPTION(runtime_error("Not implemented."));
|
/* Fully contained in the specified range? */
|
||||||
|
if (segment->Get("begin") >= begin && segment->Get("end") <= end)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Not overlapping at all? */
|
||||||
|
if (segment->Get("end") < begin || segment->Get("begin") > end) {
|
||||||
|
newSegments->Add(segment);
|
||||||
|
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Create a new segment and adjust its begin/end timestamps
|
||||||
|
* so as to not overlap with the specified range. */
|
||||||
|
Dictionary::Ptr newSegment = boost::make_shared<Dictionary>();
|
||||||
|
newSegment->Set("begin", (segment->Get("begin") < end) ? end : segment->Get("begin"));
|
||||||
|
newSegment->Set("end", (segment->Get("end") > begin) ? begin : segment->Get("end"));
|
||||||
|
|
||||||
|
newSegments->Add(newSegment);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Segments = newSegments;
|
||||||
Touch("segments");
|
Touch("segments");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user