Changeset 8:856953e5e942 in rrlib_data_fusion


Ignore:
Timestamp:
09.11.2011 14:03:34 (9 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Message:

Added a few exceptions

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • functions.h

    r6 r8  
    3838// External includes (system with <>, local with "") 
    3939//---------------------------------------------------------------------- 
     40#include <stdexcept> 
    4041 
    4142//---------------------------------------------------------------------- 
     
    7576{ 
    7677  tMaximumKey<TSample> fuser; 
     78  if (begin_samples == end_samples) 
     79  { 
     80    throw std::logic_error("Given empty list of samples!"); 
     81  } 
    7782  fuser.SetNumberOfChannels(std::distance(begin_samples, end_samples)); 
    7883  fuser.UpdateAllChannels(begin_samples, end_samples, begin_keys, end_keys); 
     
    8489{ 
    8590  tAverage<TSample> fuser; 
     91  if (begin_samples == end_samples) 
     92  { 
     93    throw std::logic_error("Given empty list of samples!"); 
     94  } 
    8695  fuser.SetNumberOfChannels(std::distance(begin_samples, end_samples)); 
    8796  fuser.UpdateAllChannels(begin_samples, end_samples); 
     
    93102{ 
    94103  tWeightedAverage<TSample> fuser; 
     104  if (begin_samples == end_samples) 
     105  { 
     106    throw std::logic_error("Given empty list of samples!"); 
     107  } 
    95108  fuser.SetNumberOfChannels(std::distance(begin_samples, end_samples)); 
    96109  fuser.UpdateAllChannels(begin_samples, end_samples, begin_keys, end_keys); 
     
    102115{ 
    103116  tMedianVoter<TSample> fuser; 
     117  if (begin_samples == end_samples) 
     118  { 
     119    throw std::logic_error("Given empty list of samples!"); 
     120  } 
    104121  fuser.SetNumberOfChannels(std::distance(begin_samples, end_samples)); 
    105122  fuser.UpdateAllChannels(begin_samples, end_samples); 
     
    111128{ 
    112129  tMedianKeyVoter<TSample> fuser; 
     130  if (begin_samples == end_samples) 
     131  { 
     132    throw std::logic_error("Given empty list of samples!"); 
     133  } 
    113134  fuser.SetNumberOfChannels(std::distance(begin_samples, end_samples)); 
    114135  fuser.UpdateAllChannels(begin_samples, end_samples, begin_keys, end_keys); 
  • tDataFusion.hpp

    r6 r8  
    139139const bool tDataFusion<TSample, TChannel>::IsValid() const 
    140140{ 
     141  if (this->channels.empty()) 
     142  { 
     143    throw std::logic_error("Number of channels must be greater than zero!"); 
     144  } 
    141145  for (typename std::vector<TChannel<TSample>>::const_iterator it = this->channels.begin(); it != this->channels.end(); ++it) 
    142146  { 
     
    146150    } 
    147151  } 
    148   return this->channels.size() > 0 && this->HasValidState(); 
     152  return this->HasValidState(); 
    149153} 
    150154 
Note: See TracChangeset for help on using the changeset viewer.