00001 /* 00002 * BehaviorHelper.hpp 00003 * 00004 * Created on: Nov 17, 2011 00005 * Author: mriedel 00006 */ 00007 00008 #ifndef BEHAVIORHELPER_HPP_ 00009 #define BEHAVIORHELPER_HPP_ 00010 00011 #include <telekyb_defines/telekyb_defines.hpp> 00012 #include <tk_behavior/BehaviorType.hpp> 00013 00014 #include <tk_behavior/Behavior.hpp> 00015 00016 namespace TELEKYB_NAMESPACE { 00017 00018 class BehaviorHelper { 00019 public: 00020 static bool isAllowedTypeTransition(const BehaviorType& from, const BehaviorType& to); 00021 static bool isAllowedBehaviorTransition(const Behavior& from, const Behavior& to); 00022 00023 }; 00024 00025 inline 00026 bool BehaviorHelper::isAllowedTypeTransition(const BehaviorType& from, const BehaviorType& to) { 00027 00028 return ( 00029 (from == BehaviorType::Air && to == BehaviorType::Air) || // Air -> Air 00030 (from == BehaviorType::TakeOff && to == BehaviorType::Air) || // Takeoff -> Air 00031 (from == BehaviorType::Air && to == BehaviorType::Land) || // Air -> Land 00032 (from == BehaviorType::TakeOff && to == BehaviorType::Land) || // TakeOff->Land 00033 (from == BehaviorType::Ground && to == BehaviorType::TakeOff) || // Ground -> Takeoff 00034 (from == BehaviorType::Land && to == BehaviorType::Ground) || // Land -> Ground 00035 (from == BehaviorType::Ground && to == BehaviorType::Ground) // Ground -> Ground 00036 ); 00037 } 00038 00039 inline 00040 bool BehaviorHelper::isAllowedBehaviorTransition(const Behavior& from, const Behavior& to) { 00041 return isAllowedTypeTransition(from.getType(), to.getType()); 00042 } 00043 00044 } // namespace 00045 00046 #endif /* BEHAVIORHELPER_HPP_ */