Keywords.cpp
Go to the documentation of this file.
00001 #include "ias_drawer_executive/Keywords.h"
00002 #include <string>
00003 #include <ros/ros.h>
00004 #include <tf/tf.h>
00005 
00006 Keywords::Keywords(std::string name, double val)
00007 {
00008     parameters_d[name] = val;
00009 };
00010 
00011 Keywords &Keywords::operator()(std::string name, double val)
00012 {
00013     parameters_d[name] = val;
00014     return *this;
00015 };
00016 
00017 Keywords::Keywords(std::string name, std::string val)
00018 {
00019     parameters_s[name] = val;
00020 };
00021 
00022 Keywords &Keywords::operator()(std::string name, std::string val)
00023 {
00024     parameters_s[name] = val;
00025     return *this;
00026 };
00027 
00028 Keywords::Keywords(std::string name, tf::Vector3 val)
00029 {
00030     parameters_v[name] = val;
00031 };
00032 
00033 Keywords &Keywords::operator()(std::string name, tf::Vector3 val)
00034 {
00035     parameters_v[name] = val;
00036     return *this;
00037 };
00038 
00039 
00040 Keywords &Keywords::contains()
00041 {
00042     std::cout << "Contains :" << std::endl;
00043     {
00044         std::map<std::string,double>::iterator iter;
00045         for (iter = parameters_d.begin(); iter != parameters_d.end(); iter++ )
00046             std::cout << iter->first << ":" << iter->second << std::endl;
00047     }
00048     {
00049         std::map<std::string,std::string>::iterator iter;
00050         for (iter = parameters_s.begin(); iter != parameters_s.end(); iter++ )
00051             std::cout << iter->first << ":" << iter->second << std::endl;
00052     }
00053     {
00054         std::map<std::string,tf::Vector3>::iterator iter;
00055         for (iter = parameters_v.begin(); iter != parameters_v.end(); iter++ )
00056             std::cout << iter->first << ":" << iter->second.x() << " "  << iter->second.y() << " " << iter->second.z() << std::endl;
00057     }
00058 
00059 
00060     return *this;
00061 };
00062 
00063 
00064 bool Keywords::has_d(const std::string &key) const
00065 {
00066     if (parameters_d.find(key) != parameters_d.end())
00067         return true;
00068     else
00069         return false;
00070 };
00071 
00072 bool Keywords::has_s(const std::string &key) const
00073 {
00074     if (parameters_s.find(key) != parameters_s.end())
00075         return true;
00076     else
00077         return false;
00078 };
00079 
00080 bool Keywords::has_v(const std::string &key) const
00081 {
00082     if (parameters_v.find(key) != parameters_v.end())
00083         return true;
00084     else
00085         return false;
00086 };
00087 
00088 double Keywords::lookup_d(const std::string &key) const
00089 {
00090     std::map<std::string,double>::const_iterator it = parameters_d.find(key);
00091     if (it != parameters_d.end())
00092         return it->second; // we cant use map[key] since its a modifier
00093     else return 0;
00094     // else throw ...
00095 };
00096 
00097 std::string Keywords::lookup_s(const std::string &key) const
00098 {
00099     std::map<std::string,std::string>::const_iterator it = parameters_s.find(key);
00100     if (it != parameters_s.end())
00101         return it->second;
00102     else return "";
00103     // else throw ...
00104 };
00105 
00106 tf::Vector3 Keywords::lookup_v(const std::string &key) const
00107 {
00108     std::map<std::string,tf::Vector3>::const_iterator it = parameters_v.find(key);
00109     if (it != parameters_v.end())
00110         return it->second;
00111     else return tf::Vector3(0,0,0);
00112     // else throw ...
00113 };
00114 
00115 KeyValPair Keywords::lookup(const std::string &key) const
00116 {
00117     KeyValPair kvp;
00118     {
00119         std::map<std::string,tf::Vector3>::const_iterator it = parameters_v.find(key);
00120         if (it != parameters_v.end())
00121             kvp.v = it->second;
00122     }
00123     {
00124         std::map<std::string,std::string>::const_iterator it = parameters_s.find(key);
00125         if (it != parameters_s.end())
00126             kvp.s = it->second;
00127     }
00128     {
00129         std::map<std::string,double>::const_iterator it = parameters_d.find(key);
00130         if (it != parameters_d.end())
00131             kvp.d = it->second;
00132     }
00133     return kvp;
00134 }
00135 
00136 
00137 


ias_drawer_executive
Author(s): Thomas Ruehr
autogenerated on Mon Oct 6 2014 08:59:22