/******************************************************************************/ /* */ /* SEGMENTCRITERIA.HH */ /* */ /******************************************************************************/ // Shourov K. Chatterji // shourov@ligo.mit.edu // 2004-Sep-27 /* Protect against double inclusion */ /* -------------------------------- */ #ifndef SEGMENTCRITERIA_HH #define SEGMENTCRITERIA_HH /* Include header files */ /* -------------------- */ #include #include "event.hh" #include "segment.hh" /* Begin namespace segment */ /* ----------------------- */ namespace segment { /* Segment Sort Criteria */ /* --------------------- */ // base class for segment sort criteria struct SegmentSortCriterion : public std::binary_function { SegmentSortCriterion() {} virtual ~SegmentSortCriterion() {} virtual bool operator()(const Segment& segment1, const Segment& segment2) =0; }; // sort segments by increasing start time struct IncreasingSegmentStartTimeSortCriterion : public SegmentSortCriterion { bool operator()(const Segment& segment1, const Segment& segment2) { return segment1.getStartTime() < segment2.getStartTime(); } }; // sort segments by decreasing start time struct DecreasingSegmentStartTimeSortCriterion : public SegmentSortCriterion { bool operator()(const Segment& segment1, const Segment& segment2) { return segment1.getStartTime() > segment2.getStartTime(); } }; // sort segments by increasing stop time struct IncreasingSegmentStopTimeSortCriterion : public SegmentSortCriterion { bool operator()(const Segment& segment1, const Segment& segment2) { return segment1.getStopTime() < segment2.getStopTime(); } }; // sort segments by decreasing stop time struct DecreasingSegmentStopTimeSortCriterion : public SegmentSortCriterion { bool operator()(const Segment& segment1, const Segment& segment2) { return segment1.getStopTime() > segment2.getStopTime(); } }; // sort segments by increasing duration struct IncreasingSegmentDurationSortCriterion : public SegmentSortCriterion { bool operator()(const Segment& segment1, const Segment& segment2) { return segment1.getDuration() < segment2.getDuration(); } }; // sort segments by decreasing duration struct DecreasingSegmentDurationSortCriterion : public SegmentSortCriterion { bool operator()(const Segment& segment1, const Segment& segment2) { return segment1.getDuration() > segment2.getDuration(); } }; /* Segment Cut Criteria */ /* -------------------- */ // base class for segment cut criteria struct SegmentCutCriterion : public std::unary_function { SegmentCutCriterion() {} virtual ~SegmentCutCriterion() {} virtual bool operator()(const Segment& segment) =0; }; // cut segments with start time less than threshold struct SegmentStartTimeLessThanCutCriterion : public SegmentCutCriterion { SegmentStartTimeLessThanCutCriterion(double threshold) : threshold(threshold) {} bool operator()(const Segment& segment) { return segment.getStartTime() < threshold; } double threshold; }; // cut segments with start time greater than threshold struct SegmentStartTimeGreaterThanCutCriterion : public SegmentCutCriterion { SegmentStartTimeGreaterThanCutCriterion(double threshold) : threshold(threshold) {} bool operator()(const Segment& segment) { return segment.getStartTime() >= threshold; } double threshold; }; // cut segments with stop time less than threshold struct SegmentStopTimeLessThanCutCriterion : public SegmentCutCriterion { SegmentStopTimeLessThanCutCriterion(double threshold) : threshold(threshold) {} bool operator()(const Segment& segment) { return segment.getStopTime() < threshold; } double threshold; }; // cut segments with stop time greater than threshold struct SegmentStopTimeGreaterThanCutCriterion : public SegmentCutCriterion { SegmentStopTimeGreaterThanCutCriterion(double threshold) : threshold(threshold) {} bool operator()(const Segment& segment) { return segment.getStopTime() >= threshold; } double threshold; }; // cut segments with duration less than threshold struct SegmentDurationLessThanCutCriterion : public SegmentCutCriterion { SegmentDurationLessThanCutCriterion(double threshold) : threshold(threshold) {} bool operator()(const Segment& segment) { return segment.getDuration() < threshold; } double threshold; }; // cut segments with duration greater than threshold struct SegmentDurationGreaterThanCutCriterion : public SegmentCutCriterion { SegmentDurationGreaterThanCutCriterion(double threshold) : threshold(threshold) {} bool operator()(const Segment& segment) { return segment.getDuration() >= threshold; } double threshold; }; /* Segment Coincidence Criteria */ /* ---------------------------- */ // base class for segment coincidence criteria struct SegmentCoincidenceCriterion : public std::binary_function { SegmentCoincidenceCriterion() {} virtual ~SegmentCoincidenceCriterion() {} virtual bool operator()(const Segment& segment1, const Segment& segment2) { return (segment1.getStartTime() < segment2.getStopTime()) && (segment2.getStartTime() < segment1.getStopTime()); } }; /* End namespace segment */ /* --------------------- */ } /* End protection against double inclusion */ /* --------------------------------------- */ #endif