00001 // vim:set et sts=4 ts=4 tw=75 sw=4 ai ci cin cino=g0,t0: 00002 /* 00003 * Copyright (C) 2007, Technical Computer Science Group, 00004 * University of Bonn 00005 * 00006 * This file is part of the ReChannel library. 00007 * 00008 * The ReChannel library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU General Public License as 00010 * published by the Free Software Foundation; either version 2 of the 00011 * License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be 00014 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this library; see the file COPYING. If not, write to the 00020 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 00021 * Boston, MA 02110-1301, USA. 00022 * 00023 * Authors: Andreas Raabe and Armin Felke. Implementation by Armin Felke. 00024 * {raabe, felke}@cs.uni-bonn.de 00025 */ 00037 #ifndef RC_RECONFIGURABLE_SET_H_ 00038 #define RC_RECONFIGURABLE_SET_H_ 00039 00040 #include "ReChannel/core/rc_common_header.h" 00041 00042 namespace ReChannel { 00043 00044 class rc_reconfigurable; 00045 00060 class rc_reconfigurable_set 00061 : private std::set<rc_reconfigurable*> 00062 { 00066 friend class rc_control; 00067 00068 private: 00072 typedef std::set<rc_reconfigurable*> base_type; 00073 00074 public: 00078 typedef base_type::iterator iterator; 00082 typedef base_type::const_iterator const_iterator; 00083 00084 public: 00090 rc_reconfigurable_set() { } 00091 00095 rc_reconfigurable_set(const rc_reconfigurable_set& reconf_set) 00096 : base_type(reconf_set) 00097 { } 00098 00102 inline rc_reconfigurable_set& operator=( 00103 const rc_reconfigurable_set& reconf_set) 00104 { base_type::operator=(reconf_set); return *this; } 00105 00109 inline int size() const 00110 { return (int)base_type::size(); } 00111 00115 inline void insert(rc_reconfigurable& reconf) 00116 { base_type::insert(&reconf); } 00117 00121 inline void insert(const rc_reconfigurable_set& reconf_set) 00122 { base_type::insert(reconf_set.begin(), reconf_set.end()); } 00123 00127 inline void erase(rc_reconfigurable& reconf) 00128 { base_type::erase(&reconf); } 00129 00133 void erase(const rc_reconfigurable_set& reconf_set); 00134 00138 inline bool contains(const rc_reconfigurable& reconf) const 00139 { 00140 return (base_type::find(const_cast<rc_reconfigurable*>(&reconf)) 00141 != base_type::end()); 00142 } 00143 00147 bool contains(const rc_reconfigurable_set& reconf_set) const; 00148 00152 inline iterator find(rc_reconfigurable& reconf) 00153 { return base_type::find(&reconf); } 00154 00158 inline const_iterator find(const rc_reconfigurable& reconf) const 00159 { 00160 return base_type::find( 00161 const_cast<rc_reconfigurable*>(&reconf)); 00162 } 00163 00167 inline iterator begin() 00168 { return base_type::begin(); } 00169 00173 inline const_iterator begin() const 00174 { return base_type::begin(); } 00175 00179 inline iterator end() 00180 { return base_type::end(); } 00181 00185 inline const_iterator end() const 00186 { return base_type::end(); } 00187 00188 inline rc_reconfigurable_set& operator+=( 00189 rc_reconfigurable& reconf) 00190 { this->insert(reconf); return *this; } 00191 00192 inline rc_reconfigurable_set& operator+=( 00193 const rc_reconfigurable_set& reconf_set) 00194 { this->insert(reconf_set); return *this; } 00195 00196 inline rc_reconfigurable_set operator+( 00197 rc_reconfigurable& reconf) const 00198 { return (rc_reconfigurable_set(*this) += reconf); } 00199 00200 inline rc_reconfigurable_set operator+( 00201 const rc_reconfigurable_set& reconf_set) const 00202 { return (rc_reconfigurable_set(*this) += reconf_set); } 00203 00204 inline rc_reconfigurable_set& operator-=( 00205 rc_reconfigurable& reconf) 00206 { this->erase(reconf); return *this; } 00207 00208 inline rc_reconfigurable_set& operator-=( 00209 const rc_reconfigurable_set& reconf_set) 00210 { this->erase(reconf_set); return *this; } 00211 00212 inline rc_reconfigurable_set operator-( 00213 rc_reconfigurable& reconf) const 00214 { return (rc_reconfigurable_set(*this) -= reconf); } 00215 00216 inline rc_reconfigurable_set operator-( 00217 const rc_reconfigurable_set& reconf_set) const 00218 { return (rc_reconfigurable_set(*this) -= reconf_set); } 00219 }; 00220 00221 /* global functions */ 00222 00223 inline rc_reconfigurable_set operator+( 00224 rc_reconfigurable& dyn_object1, rc_reconfigurable& dyn_object2) 00225 { 00226 return ((rc_reconfigurable_set() += dyn_object1) += dyn_object2); 00227 } 00228 inline rc_reconfigurable_set operator+( 00229 rc_reconfigurable& reconf, 00230 const rc_reconfigurable_set& reconf_set) 00231 { 00232 return (rc_reconfigurable_set(reconf_set) += reconf); 00233 } 00234 00235 } // namespace ReChannel 00236 00237 #endif // RC_RECONFIGURABLE_SET_H_ 00238 00239 // 00240 // $Id: rc_reconfigurable_set.h,v 1.7 2007/12/20 20:39:40 felke Exp $ 00241 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/core/rc_reconfigurable_set.h,v $ 00242 // 00243