// PlacementCategory.h #ifndef hes_PlacementCategory_H #define hes_PlacementCategory_H // David Adams // February 2002 // // A placement category holds a collection of valid EDO ID's. // The category also hold a type which has a name and specifies // which type-keys are allowed. #include #include #include "hesbase/Name.h" #include "hesbase/EventId.h" #include "hesbase/EdoType.h" #include "hesbase/EdoKey.h" #include "hesbase/EdoTypeKey.h" #include "hesbase/EdoId.h" #include "PlacementCategoryType.h" namespace hes { class PlacementCategory { public: // typedefs // Collection of EDO ID's. typedef std::vector EdoIdList; // Type for size of this collection. typedef std::vector::size_type size_type; private: // data // The type. const PlacementCategoryType* m_ptype; // The event ID. EventId m_evid; // Flag indicating the object is closed. bool m_closed; // The list of EDO ID's. EdoIdList m_ids; public: // non-const functions // Default constructor. // Creates an invalid object. PlacementCategory(); // Constructor from a placement category type and an event ID. // The type must be valid and closed and the event ID must be valid. // This object assumes the placement category type will not change // or be deleted. PlacementCategory(const PlacementCategoryType& pct, EventId evid); // Add an EDO ID. // This object must be valid and not be closed. // The ID must // 1. be valid, // 2. be allowed by the type, // 3. have the same event ID as this object // 4. not replicate any previous type-keys. // Returns zero for success. int insert(EdoId id); // Close the object. // Insertions may only occur before this call. void close(); public: // const functions // Is this object valid? // Valid if it has a valid type. bool is_valid() const; // Is the object closed? bool is_closed() const; // Return the name of the placement category type. // Returns invalid if this object is not valid. Name name() const; // Return the placement category type. // Returns an invalid type if this object is not valid. const PlacementCategoryType& type() const; // Return the event ID. EventId event_id() const; // Return the number of EDO ID's. size_type size() const; // Return the list of EDO ID's. const EdoIdList& edo_ids() const; // Return if the category includes a specified type-key. bool has(EdoTypeKey tk) const; bool has(EdoType type, EdoKey key) const; // Find the EDO ID with the specified type-key. // If there is no match, an invalid ID is returned. EdoId edo_id(EdoTypeKey tk) const; EdoId edo_id(EdoType type, EdoKey key) const; }; } // end namespace // Output stream. std::ostream& operator<<(std::ostream& lhs, const hes::PlacementCategory& rhs); #endif