libssrckdtree 1.0.8 C++ Unit Test Coverage
Current view: top level - ssrc/spatial/detail - coordinate_limits.h (source / functions) Hit Total Coverage
Test: libssrckdtree 1.0.8 C++ Unit Tests Lines: 8 8 100.0 %
Date: 2011-06-03 Functions: 6 6 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright 2009 Savarese Software Research Corporation
       3                 :            :  *
       4                 :            :  * Licensed under the Apache License, Version 2.0 (the "License");
       5                 :            :  * you may not use this file except in compliance with the License.
       6                 :            :  * You may obtain a copy of the License at
       7                 :            :  *
       8                 :            :  *     https://www.savarese.com/software/ApacheLicense-2.0
       9                 :            :  *
      10                 :            :  * Unless required by applicable law or agreed to in writing, software
      11                 :            :  * distributed under the License is distributed on an "AS IS" BASIS,
      12                 :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13                 :            :  * See the License for the specific language governing permissions and
      14                 :            :  * limitations under the License.
      15                 :            :  */
      16                 :            : 
      17                 :            : #ifndef __SSRC_SPATIAL_DETAIL_COORDINATE_LIMITS_H
      18                 :            : #define __SSRC_SPATIAL_DETAIL_COORDINATE_LIMITS_H
      19                 :            : 
      20                 :            : #include <ssrc/libssrckdtree-packages.h>
      21                 :            : 
      22                 :            : #include <limits>
      23                 :            : 
      24                 :            : __BEGIN_NS_SSRC_SPATIAL
      25                 :            : 
      26                 :            : namespace detail {
      27                 :            : 
      28                 :            :   template<typename coordinate_type, bool is_integer, bool has_infinity>
      29                 :            :   struct coordinate_limits_impl;
      30                 :            : 
      31                 :            :   template<typename coordinate_type>
      32                 :            :   struct coordinate_limits_impl<coordinate_type, true, false> {
      33                 :          2 :     static const coordinate_type highest() {
      34                 :          2 :       return std::numeric_limits<coordinate_type>::max();
      35                 :            :     }
      36                 :          2 :     static const coordinate_type lowest() {
      37                 :          2 :       return std::numeric_limits<coordinate_type>::min();
      38                 :            :     }
      39                 :            :   };
      40                 :            : 
      41                 :            :   template<typename coordinate_type>
      42                 :            :   struct coordinate_limits_impl<coordinate_type, false, false> {
      43                 :            :     static const coordinate_type highest() {
      44                 :            :       return std::numeric_limits<coordinate_type>::max();
      45                 :            :     }
      46                 :            :     static const coordinate_type lowest() {
      47                 :            :       // Note, for C++0x, this should be std::numeric_limits::lowest()
      48                 :            :       // because not all environments have floating point type implementations
      49                 :            :       // where the most negative value is equal to the negative maximum value.
      50                 :            :       // But no known compilers yet implement std::numeric_limits::lowest().
      51                 :            :       return -std::numeric_limits<coordinate_type>::max();
      52                 :            :     }
      53                 :            :   };
      54                 :            : 
      55                 :            :   template<typename coordinate_type>
      56                 :            :   struct coordinate_limits_impl<coordinate_type, false, true> {
      57                 :        109 :     static const coordinate_type highest() {
      58                 :        109 :       return std::numeric_limits<coordinate_type>::infinity();
      59                 :            :     }
      60                 :          1 :     static const coordinate_type lowest() {
      61                 :          1 :       return -std::numeric_limits<coordinate_type>::infinity();
      62                 :            :     }
      63                 :            :   };
      64                 :            : 
      65                 :            :   // <coordinate_type, true, true> is a compile-time error.
      66                 :            : 
      67                 :            :   template<typename coordinate_type>
      68                 :            :   struct coordinate_limits : public coordinate_limits_impl<coordinate_type, std::numeric_limits<coordinate_type>::is_integer, std::numeric_limits<coordinate_type>::has_infinity> { };
      69                 :            : }
      70                 :            : 
      71                 :            : __END_NS_SSRC_SPATIAL
      72                 :            : 
      73                 :            : #endif