#ifndef CUTRECORDER_HPP #define CUTRECORDER_HPP //======================================================================== // // Name: CutRecorder.hpp // // Purpose: Class to maintain a list of cuts stored in CutRecords. This // class is implemented as a singleton. // // Created: 29-Jun-2000 H. Greenlee // //======================================================================== #include #include #include #include #include "CutRecord.hpp" namespace trf { class CutRecorder { public: // typedefs // Have to use deque container for CutRecords so that a) CutRecords are // not relocated as container grows (PTracks maintain borrowed references // to CutRecords, and b) container allows random access. typedef std::deque CutRecordList; // Static instance method. static CutRecorder* instance(); // Operators. CutRecord& operator[](int id) {return get_record(id);} const CutRecord& operator[](int id) const {return get_record(id);} // Global flags. bool enabled() const {return _enable;} void set_enable(bool enable = true) {_enable = enable;} bool record_all_cuts() const {return _record_all_cuts;} void set_record_all_cuts(bool flag = true) {_record_all_cuts = flag;} // Cut registry methods. CutID register_cut(const std::string& name); bool has_cut(const std::string& name) const; bool has_cut(const CutID& id) const; CutID get_cutid(const std::string& name) const; int get_dimension(const std::string& name) const; std::string get_cutname(const CutID& id) const; int get_dimension(const CutID& id) const; std::list registered_cuts() const; // Cut record data collection methods. void clear(); // Clear cut collections (leaves cut registry intact). CutRecord* make_cut_record(int parent_id, int ptrack_id, int path_id); // Cut record data access methods. int num_records() const {return _cuts.size();} bool has_record(int id) const; CutRecord& get_record(int id); const CutRecord& get_record(int id) const; const CutRecordList& get_record_list() const {return _cuts;} private: // Constructor, destructor. CutRecorder(); ~CutRecorder(); // Uncopyable. CutRecorder(const CutRecorder&); CutRecorder& operator=(const CutRecorder&); // Static instance attribute. static CutRecorder* _instance; // Attributes. int _next_cutid; // Value of next cut id. bool _enable; // Global enable flag. bool _record_all_cuts; // Record all cuts flag // (whether or not registered). std::map > _registered_cuts1; // Cut registry. std::map > _registered_cuts2; // Cut registry. CutRecordList _cuts; // Cuts (index = record id). }; } // end namespace trf #endif