1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _BGFX_RANGE_RANGEEXPANDER_HXX 25 #define _BGFX_RANGE_RANGEEXPANDER_HXX 26 27 #include <basegfx/range/b1drange.hxx> 28 #include <basegfx/range/b1irange.hxx> 29 #include <basegfx/range/b2drange.hxx> 30 #include <basegfx/range/b2irange.hxx> 31 #include <basegfx/range/b3drange.hxx> 32 #include <basegfx/range/b3irange.hxx> 33 34 namespace basegfx 35 { 36 /** Generic functor for expanding a range with a number of other 37 ranges. 38 39 Since *Range::expand() is overloaded, straight-forward 40 application of ::boost::bind and friends fails (because of 41 ambiguities). Thus, this functor template can be used, to 42 expand the given range with a number of other ranges, passed 43 in at the function operator. 44 45 @tpl RangeType 46 Range type to operate with. Preferrably, one of B1*Range, 47 B2*Range, or B3*Range. 48 */ 49 template< typename RangeType > class RangeExpander 50 { 51 public: 52 typedef RangeType ValueType; 53 typedef void result_type; 54 RangeExpander(ValueType & rBounds)55 explicit RangeExpander( ValueType& rBounds ) : 56 mrBounds( rBounds ) 57 { 58 } 59 operator ()(const ValueType & rBounds)60 void operator()( const ValueType& rBounds ) 61 { 62 mrBounds.expand( rBounds ); 63 } 64 65 private: 66 ValueType& mrBounds; 67 }; 68 69 typedef RangeExpander< B1DRange > B1DRangeExpander; 70 typedef RangeExpander< B1IRange > B1IRangeExpander; 71 typedef RangeExpander< B2DRange > B2DRangeExpander; 72 typedef RangeExpander< B2IRange > B2IRangeExpander; 73 typedef RangeExpander< B3DRange > B3DRangeExpander; 74 typedef RangeExpander< B3IRange > B3IRangeExpander; 75 76 } // end of namespace basegfx 77 78 79 #endif /* _BGFX_RANGE_RANGEEXPANDER_HXX */ 80