eXpress “1.5”

src/bundles.h

00001 
00009 #ifndef express_bundles_h
00010 #define express_bundles_h
00011 
00012 #include <boost/thread.hpp>
00013 #include <boost/unordered_map.hpp>
00014 #include <boost/unordered_set.hpp>
00015 #include <vector>
00016 
00017 class Target;
00018 typedef size_t TargID;
00019 typedef boost::unordered_map<size_t, float> CovarMap;
00020 
00028 class CovarTable {
00034   CovarMap _covar_map;
00035 
00036 public:
00040   CovarTable() {};
00050   void increment(TargID targ1, TargID targ2, double covar);
00058    double get(TargID targ1, TargID targ2);
00064   size_t size() const { return _covar_map.size(); }
00065 };
00066 
00067 class BundleTable;
00068 
00076 class Bundle {
00080   std::vector<Target*> _targets;
00085   size_t _counts;
00090   double _mass;
00095   Bundle* _merged_into;
00099   mutable boost::mutex _mut;
00100   
00101   friend class BundleTable;
00102 
00103 public:
00108   Bundle(Target* targ);
00115   const Bundle* get_rep() const;
00121   void incr_counts(size_t incr_amt=1);
00127   void incr_mass(double incr_amt);
00132   void reset_mass();
00137   size_t size() const;
00143   const std::vector<Target*>* targets() const { return &_targets; }
00149   size_t counts() const;
00155   double mass() const;
00156 };
00157 
00158 typedef boost::unordered_set<Bundle*> BundleSet;
00159 
00168 class BundleTable {
00172   BundleSet _bundles;
00176   bool _threadsafe_mode;
00180   mutable boost::mutex _mut;
00187   Bundle* get_rep(Bundle* b);
00188 public:
00192   BundleTable();
00196   ~BundleTable();
00203   const BundleSet& bundles() const { return _bundles; }
00208   size_t size() const { return _bundles.size(); }
00215   Bundle* create_bundle(Target* targ);
00223   Bundle* merge(Bundle* b1, Bundle* b2);
00228   void collapse();
00233   bool threadsafe_mode() const { return _threadsafe_mode; }
00239   void threadsafe_mode(bool mode) { _threadsafe_mode = mode; }
00240 };
00241 
00242 #endif
 All Classes Functions Variables