|
PPL
0.12.1
|
00001 /* Threshold_Watcher and associated classes' implementation: inline functions. 00002 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it> 00003 Copyright (C) 2010-2012 BUGSENG srl (http://bugseng.com) 00004 00005 This file is part of the Parma Polyhedra Library (PPL). 00006 00007 The PPL is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 The PPL is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software Foundation, 00019 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. 00020 00021 For the most up-to-date information see the Parma Polyhedra Library 00022 site: http://bugseng.com/products/ppl/ . */ 00023 00024 #ifndef PPL_Threshold_Watcher_inlines_hh 00025 #define PPL_Threshold_Watcher_inlines_hh 1 00026 00027 #include <stdexcept> 00028 00029 #include "Handler.defs.hh" 00030 00031 namespace Parma_Polyhedra_Library { 00032 00033 template <typename Traits> 00034 template <typename Flag_Base, typename Flag> 00035 Threshold_Watcher<Traits> 00036 ::Threshold_Watcher(const typename Traits::Delta& delta, 00037 const Flag_Base* volatile& holder, 00038 Flag& flag) 00039 : expired(false), 00040 handler(*new 00041 Implementation::Watchdog::Handler_Flag<Flag_Base, Flag>(holder, 00042 flag)) { 00043 typename Traits::Threshold threshold; 00044 Traits::from_delta(threshold, delta); 00045 if (!Traits::less_than(Traits::get(), threshold)) 00046 throw std::invalid_argument("Threshold_Watcher constructor called with a" 00047 " threshold already reached"); 00048 pending_position = add_threshold(threshold, handler, expired); 00049 } 00050 00051 template <typename Traits> 00052 inline 00053 Threshold_Watcher<Traits>::Threshold_Watcher(const typename Traits::Delta& delta, void (*function)()) 00054 : expired(false), 00055 handler(*new Implementation::Watchdog::Handler_Function(function)) { 00056 typename Traits::Threshold threshold; 00057 Traits::from_delta(threshold, delta); 00058 if (!Traits::less_than(Traits::get(), threshold)) 00059 throw std::invalid_argument("Threshold_Watcher constructor called with a" 00060 " threshold already reached"); 00061 pending_position = add_threshold(threshold, handler, expired); 00062 } 00063 00064 } // namespace Parma_Polyhedra_Library 00065 00066 #endif // !defined(PPL_Threshold_Watcher_inlines_hh)