RosTopicListener.h
Go to the documentation of this file.
00001 /*
00002  * RosTopicListener.h
00003  *
00004  *  Created on: Oct 27, 2013
00005  *      Author: blackpc
00006  */
00007 
00008 #ifndef ROSTOPICLISTENER_H_
00009 #define ROSTOPICLISTENER_H_
00010 
00011 #include <iostream>
00012 #include <set>
00013 #include <python2.7/Python.h>
00014 #include <boost/thread.hpp>
00015 #include <boost/foreach.hpp>
00016 
00017 #include <scriptable_monitor/scripts/RosTopicListenerPython.h>
00018 #include <scriptable_monitor/PythonExecuter.h>
00019 
00020 #define foreach BOOST_FOREACH
00021 
00022 #define debugPrint(str) std::cout << __FILE__  << ":" << __LINE__ << str << std::endl
00023 
00024 //#define lock(mutexObject)     debugPrint(" + Locking..."<<#mutexObject);\
00025 //                                                      boost::mutex::scoped_lock mutexObject##ScopedLock(mutexObject);\
00026 //                                                      debugPrint(" - Locked!"<<#mutexObject);
00027 
00028 #define lock(mutexObject) boost::mutex::scoped_lock mutexObject##ScopedLock(mutexObject)
00029 #define lock_recursive(mutexObject) boost::recursive_mutex::scoped_lock mutexObject##ScopedLock(mutexObject)
00030 
00031 using namespace std;
00032 
00033 class RosTopicListener
00034 {
00035 public:
00036 
00037         static void start();
00038         static void stop();
00039         static void addTopic(string topicName);
00040         static void removeTopic(string topicName);
00041         static vector<string> getTopics();
00042         static string getTopicValue(string topicName);
00043         static map<string, string> getTopicsValues();
00044         static bool hasTopicValue(string topicName);
00045 
00046 private:
00047         static boost::mutex _activeTopicsMutex;
00048         static boost::thread* _listeningThread;
00049         static map<string, string> _topicValues;
00050         static set<string> _activeTopics;
00051         static PyMethodDef RosTopicPythonLib[];
00052         static bool                     _running;
00053 
00054         static void listeningThread();
00055 
00056         static PyObject* internalInterruptionRequested(PyObject* self, PyObject* args);
00057         static PyObject* internalTopicUpdate(PyObject* self, PyObject* args);
00058         static PyObject* internalGetTopics(PyObject* self, PyObject* args);
00059 
00060 };
00061 
00062 #endif /* ROSTOPICLISTENER_H_ */


scriptable_monitor
Author(s):
autogenerated on Wed Aug 26 2015 16:21:30