OpenStudio:utilities
Loading...
Searching...
No Matches
openstudio::ObjectOrderBase Class Reference

#include <ObjectOrderBase.hpp>

+ Inheritance diagram for openstudio::ObjectOrderBase:

Public Member Functions

bool erase (IddObjectType type)
 Deletes type from the user-specified IddObjectType order, if it exists and contains type.
 
OptionalIddObjectTypeVector iddOrder () const
 Returns the user-specified order by IddObjectType, if it exists.
 
OptionalUnsigned indexInOrder (const IddObjectType &type) const
 Returns the index of type in IddObjectType order if ordering directly by enum, or by user-specified order.
 
bool inOrder (const IddObjectType &type) const
 Returns true if ordering by IddObjectType enum, or if ordering by user-specified IddObjectType order, and type is explicitly listed.
 
bool insert (IddObjectType type, IddObjectType insertBeforeType)
 Inserts type before insertBeforeType in the user-specified IddObjectType order, if it exists.
 
bool insert (IddObjectType type, unsigned index)
 Inserts type at index of the user-specified IddObjectType order, if it exists, and index is valid.
 
virtual bool less (boost::optional< IddObjectType > left, boost::optional< IddObjectType > right) const
 Predicate function used by derived classes to sort objects and handles.
 
virtual bool less (IddObjectType left, IddObjectType right) const
 Predicate function used by derived classes to sort objects and handles.
 
bool move (IddObjectType type, IddObjectType insertBeforeType)
 Moves type from current location and places before insertBeforeType, if a user-specified IddObjectType order exists.
 
bool move (IddObjectType type, unsigned index)
 Moves type from current location to index in user-specified IddObjectType order, if it exists.
 
 ObjectOrderBase ()
 Default constructor establishes ordering by IddObjectType enum.
 
 ObjectOrderBase (bool directOrder)
 Constructor specifies that a derived class is in charge.
 
 ObjectOrderBase (const IddObjectTypeVector &iddOrder)
 A user-specified order of IddObjectTypes is established on construction.
 
bool orderByIddEnum () const
 Returns true if ordering by IddObjectType enum.
 
bool push_back (IddObjectType type)
 Adds type to the user-specified IddObjectType order, if it exists.
 
void setDirectOrder ()
 Disables ordering by IddObjectType.
 
virtual void setIddOrder (const IddObjectTypeVector &order)
 Clears out the previous order, and establishes order as the new basis for comparison.
 
virtual void setOrderByIddEnum ()
 Clears out the previous order, and establishes IddObjectType enum as the orderer.
 
bool swap (IddObjectType type1, IddObjectType type2)
 Swaps type1 and type2 in the user-specified IddObjectType order, if it exists and contains type1 and type2.
 
virtual ~ObjectOrderBase ()=default
 

Protected Member Functions

IddObjectTypeVector::iterator getIterator (const IddObjectType &type)
 
IddObjectTypeVector::const_iterator getIterator (const IddObjectType &type) const
 

Protected Attributes

OptionalIddObjectTypeVector m_iddOrder
 
bool m_orderByIddEnum
 

Detailed Description

Base class for ordering objects.

Provides ordering by IddObjectType enum (using the implicit conversion to int), and user-specified ordering of IddObjectTypes.

Constructor & Destructor Documentation

◆ ObjectOrderBase() [1/3]

openstudio::ObjectOrderBase::ObjectOrderBase ( )

Default constructor establishes ordering by IddObjectType enum.

◆ ObjectOrderBase() [2/3]

openstudio::ObjectOrderBase::ObjectOrderBase ( bool directOrder)

Constructor specifies that a derived class is in charge.

◆ ObjectOrderBase() [3/3]

openstudio::ObjectOrderBase::ObjectOrderBase ( const IddObjectTypeVector & iddOrder)

A user-specified order of IddObjectTypes is established on construction.

◆ ~ObjectOrderBase()

virtual openstudio::ObjectOrderBase::~ObjectOrderBase ( )
virtualdefault

Member Function Documentation

◆ erase()

bool openstudio::ObjectOrderBase::erase ( IddObjectType type)

Deletes type from the user-specified IddObjectType order, if it exists and contains type.

Otherwise, returns false.

◆ getIterator() [1/2]

IddObjectTypeVector::iterator openstudio::ObjectOrderBase::getIterator ( const IddObjectType & type)
protected

◆ getIterator() [2/2]

IddObjectTypeVector::const_iterator openstudio::ObjectOrderBase::getIterator ( const IddObjectType & type) const
protected

◆ iddOrder()

OptionalIddObjectTypeVector openstudio::ObjectOrderBase::iddOrder ( ) const

Returns the user-specified order by IddObjectType, if it exists.

Otherwise return value evaluates to false.

◆ indexInOrder()

OptionalUnsigned openstudio::ObjectOrderBase::indexInOrder ( const IddObjectType & type) const

Returns the index of type in IddObjectType order if ordering directly by enum, or by user-specified order.

Otherwise, the return value evaluates to false.

◆ inOrder()

bool openstudio::ObjectOrderBase::inOrder ( const IddObjectType & type) const

Returns true if ordering by IddObjectType enum, or if ordering by user-specified IddObjectType order, and type is explicitly listed.

◆ insert() [1/2]

bool openstudio::ObjectOrderBase::insert ( IddObjectType type,
IddObjectType insertBeforeType )

Inserts type before insertBeforeType in the user-specified IddObjectType order, if it exists.

Returns false if such an order does not exist. If insertBeforeType is not in the order, this method is equivalent to push_back(type).

◆ insert() [2/2]

bool openstudio::ObjectOrderBase::insert ( IddObjectType type,
unsigned index )

Inserts type at index of the user-specified IddObjectType order, if it exists, and index is valid.

Returns false if such an order does not exist. Is equivalent to push_back(type) if index is out of range.

◆ less() [1/2]

virtual bool openstudio::ObjectOrderBase::less ( boost::optional< IddObjectType > left,
boost::optional< IddObjectType > right ) const
virtual

Predicate function used by derived classes to sort objects and handles.

Assumes uninitialized optionals are always greater than.

◆ less() [2/2]

virtual bool openstudio::ObjectOrderBase::less ( IddObjectType left,
IddObjectType right ) const
virtual

Predicate function used by derived classes to sort objects and handles.

◆ move() [1/2]

bool openstudio::ObjectOrderBase::move ( IddObjectType type,
IddObjectType insertBeforeType )

Moves type from current location and places before insertBeforeType, if a user-specified IddObjectType order exists.

Otherwise, returns false. Also returns false if type is not in the order. If insertBeforeType is not in the order, this method is equivalent to move(type,order.size()).

◆ move() [2/2]

bool openstudio::ObjectOrderBase::move ( IddObjectType type,
unsigned index )

Moves type from current location to index in user-specified IddObjectType order, if it exists.

Returns false otherwise, or if type is not in the order. If index is invalid, this method is equivalent to move(type,order.size()).

◆ orderByIddEnum()

bool openstudio::ObjectOrderBase::orderByIddEnum ( ) const

Returns true if ordering by IddObjectType enum.

◆ push_back()

bool openstudio::ObjectOrderBase::push_back ( IddObjectType type)

Adds type to the user-specified IddObjectType order, if it exists.

Returns false if such an order does not exist.

◆ setDirectOrder()

void openstudio::ObjectOrderBase::setDirectOrder ( )

Disables ordering by IddObjectType.

Is called by derived classes to signal that they are setting the order.

◆ setIddOrder()

virtual void openstudio::ObjectOrderBase::setIddOrder ( const IddObjectTypeVector & order)
virtual

Clears out the previous order, and establishes order as the new basis for comparison.

◆ setOrderByIddEnum()

virtual void openstudio::ObjectOrderBase::setOrderByIddEnum ( )
virtual

Clears out the previous order, and establishes IddObjectType enum as the orderer.

◆ swap()

bool openstudio::ObjectOrderBase::swap ( IddObjectType type1,
IddObjectType type2 )

Swaps type1 and type2 in the user-specified IddObjectType order, if it exists and contains type1 and type2.

Otherwise, returns false.

Member Data Documentation

◆ m_iddOrder

OptionalIddObjectTypeVector openstudio::ObjectOrderBase::m_iddOrder
protected

◆ m_orderByIddEnum

bool openstudio::ObjectOrderBase::m_orderByIddEnum
protected