00001 00023 #ifndef SWARM_H_ 00024 #define SWARM_H_ 00025 00026 #include <iostream> 00027 #include <vector> 00028 #include <set> 00029 #include <ros/ros.h> 00030 00031 #include "micros_swarm/singleton.h" 00032 #include "micros_swarm/runtime_handle.h" 00033 #include "micros_swarm/msg_queue_manager.h" 00034 #include "micros_swarm/packet_type.h" 00035 #include "micros_swarm/serialize.h" 00036 #include "gsdf_msgs/CommPacket.h" 00037 #include "gsdf_msgs/JoinSwarm.h" 00038 #include "gsdf_msgs/LeaveSwarm.h" 00039 00040 namespace micros_swarm{ 00041 00042 class Swarm{ 00043 public: 00044 Swarm(); 00045 Swarm(int swarm_id); 00046 Swarm(const Swarm& s); 00047 Swarm& operator=(const Swarm& s); 00048 ~Swarm(); 00049 const int id() const; 00050 const std::set<int> members(); 00051 void join(); 00052 void leave(); 00053 void select(const boost::function<bool()>& bf); 00054 void unselect(const boost::function<bool()>& bf); 00055 const bool in() const; 00056 //execute a function 00057 void execute(const boost::function<void()>& f); 00058 void breakup(); 00059 const Swarm intersection(const Swarm& s, int new_swarm_id); 00060 const Swarm swarm_union(const Swarm& s, int new_swarm_id); 00061 const Swarm difference(const Swarm& s, int new_swarm_id); 00062 const Swarm negation(int new_swarm_id); 00063 void print() const; 00064 private: 00065 int swarm_id_; 00066 boost::shared_ptr<micros_swarm::RuntimeHandle> rth_; 00067 boost::shared_ptr<micros_swarm::MsgQueueManager> mqm_; 00068 }; 00069 }; 00070 #endif