Skip to content

Commit

Permalink
add doxygen comments to fake_unit_manager.?pp
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Jun 25, 2014
1 parent 92fbce2 commit bd0688d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/fake_unit_manager.cpp
Expand Up @@ -23,6 +23,11 @@
static lg::log_domain log_engine("engine");
#define ERR_NG LOG_STREAM(err, log_engine)

/** Temporarily register a unit to be drawn on the map (moving: can overlap others).
* The temp unit is added at the end of the temporary unit dequeue,
* and therefore gets drawn last, over other units and temp units.
* Adding the same unit twice isn't allowed.
*/
void fake_unit_manager::place_temporary_unit(internal_ptr_type u)
{
if(std::find(fake_units_.begin(),fake_units_.end(), u) != fake_units_.end()) {
Expand All @@ -33,6 +38,7 @@ void fake_unit_manager::place_temporary_unit(internal_ptr_type u)
}
}

/** Removes any instances of this unit from the temporary unit database. */
int fake_unit_manager::remove_temporary_unit(internal_ptr_type u)
{
int removed = 0;
Expand Down
19 changes: 10 additions & 9 deletions src/fake_unit_manager.hpp
Expand Up @@ -21,39 +21,40 @@ class display;
class unit;
class fake_unit_ptr;

///Manages a list of fake units for the display object.
class fake_unit_manager {
public:
///Construct a fake unit manager from a display which owns it.
fake_unit_manager(display & disp) : fake_units_(), my_display_(disp) {}

//Anticipate making place_temporary_unit and remove_temporary_unit private to force exception safety
friend class fake_unit_ptr;

//Typedef internal_ptr_type is the object held internally. It should point to a const unit, since const units are drawable.
typedef unit const * internal_ptr_type;

//Typedefs and iterator methods which make this object "boost_foreachable"
typedef std::deque<internal_ptr_type>::const_iterator iterator;
typedef std::deque<internal_ptr_type>::const_iterator const_iterator;

iterator begin() { return fake_units_.begin(); }
iterator begin() { return fake_units_.begin(); }
iterator end() { return fake_units_.end(); }

const_iterator begin() const { return fake_units_.begin(); }
const_iterator end() const { return fake_units_.end(); }

private:
/** Temporarily place a unit on map (moving: can overlap others).
* The temp unit is added at the end of the temporary unit dequeue,
* and therefore gets drawn last, over other units and temp units.
* Adding the same unit twice isn't allowed.
*/
/** Register a unit with this manager. private, should only be called by fake_unit_ptr.
void place_temporary_unit(internal_ptr_type);
/** Removes any instances of this temporary unit from the temporary unit vector.
* Returns the number of temp units deleted (0 or 1, any other number indicates an error).
/** Deregister a unit from this manager. private, should only be called by fake_unit_ptr.
* @return the number of temp units deleted (0 or 1, any other number indicates an error).
*/
int remove_temporary_unit(internal_ptr_type);

/// collection of units destined to be drawn but not put into the unit map
std::deque<internal_ptr_type> fake_units_;
display & my_display_;
display & my_display_; //!< Reference to my display. The display owns me in a scoped_ptr, so this should never be a dangling reference.
};

#endif

0 comments on commit bd0688d

Please sign in to comment.