Skip to content

Commit

Permalink
style(includes): automatic reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
howardjp committed Jan 23, 2023
1 parent e56c257 commit 431a4ac
Show file tree
Hide file tree
Showing 16 changed files with 257 additions and 86 deletions.
33 changes: 26 additions & 7 deletions include/kami/agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ namespace kami {
* @param rhs is the right-hand side of the equality test.
* @return true is they are equal and false if not.
*/
friend bool operator==(const AgentID &lhs, const AgentID &rhs);
friend bool operator==(
const AgentID& lhs,
const AgentID& rhs
);

/**
* @brief Test if two `AgentID` instances are not equal.
Expand All @@ -89,7 +92,10 @@ namespace kami {
* @param rhs is the right-hand side of the equality test.
* @return true is they are not equal and false if they are.
*/
friend bool operator!=(const AgentID &lhs, const AgentID &rhs);
friend bool operator!=(
const AgentID& lhs,
const AgentID& rhs
);

/**
* @brief Test if one AgentID is less than another.
Expand All @@ -103,7 +109,10 @@ namespace kami {
* @return true if `lhs` is "less than" `rhs` as determined by the
* underlying implementation of the `AgentID`.
*/
friend bool operator<(const AgentID &lhs, const AgentID &rhs);
friend bool operator<(
const AgentID& lhs,
const AgentID& rhs
);

/**
* @brief Output an AgentID to the specified output stream
Expand All @@ -115,7 +124,10 @@ namespace kami {
* @param rhs is the `AgentID` to output
* @return the output stream for reuse
*/
friend std::ostream &operator<<(std::ostream &lhs, const AgentID &rhs);
friend std::ostream& operator<<(
std::ostream& lhs,
const AgentID& rhs
);
};

/**
Expand Down Expand Up @@ -165,7 +177,10 @@ namespace kami {
* Subclasses of Agent may chose to extend this operator to tighten
* the restrictions on the comparison.
*/
friend bool operator==(const Agent &lhs, const Agent &rhs);
friend bool operator==(
const Agent& lhs,
const Agent& rhs
);

/**
* @brief Compare if two `Agent`s are not the same `Agent`.
Expand All @@ -181,7 +196,10 @@ namespace kami {
* Subclasses of `Agent` may chose to extend this operator to tighten
* the restrictions on the comparison.
*/
friend bool operator!=(const Agent &lhs, const Agent &rhs);
friend bool operator!=(
const Agent& lhs,
const Agent& rhs
);
};

/**
Expand All @@ -196,7 +214,8 @@ namespace kami {
*
* `StagedAgents` must implement both the `step()` and `advance()` functions.
*/
class LIBKAMI_EXPORT StagedAgent : public Agent {
class LIBKAMI_EXPORT StagedAgent
: public Agent {
public:
/**
* @brief Post-step advance the agent
Expand Down
5 changes: 4 additions & 1 deletion include/kami/domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ namespace kami {
* @param rhs is the `Coord` to output
* @return the output stream for reuse
*/
friend std::ostream &operator<<(std::ostream &lhs, const Coord &rhs);
friend std::ostream& operator<<(
std::ostream& lhs,
const Coord& rhs
);
};

} // namespace kami
Expand Down
9 changes: 6 additions & 3 deletions include/kami/grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,17 @@ namespace kami {
* rectilinear grid where the cells are equal size and laid out in an ordered
* fashion.
*/
class LIBKAMI_EXPORT GridDomain : public Domain {};
class LIBKAMI_EXPORT GridDomain
: public Domain {
};

/**
* @brief An abstract for gridded coordinates.
*
* @details All gridded coordinates are expected to subclass `GridCoord`.
*/
class LIBKAMI_EXPORT GridCoord : public Coord {
class LIBKAMI_EXPORT GridCoord
: public Coord {

public:

Expand All @@ -129,7 +132,7 @@ namespace kami {
*
* @returns the distance as a `double`
*/
virtual double distance(std::shared_ptr<Coord> &p) const = 0;
virtual double distance(std::shared_ptr<Coord>& p) const = 0;

};

Expand Down
81 changes: 61 additions & 20 deletions include/kami/grid1d.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ namespace kami {
/**
* @brief One-dimensional coordinates
*/
class LIBKAMI_EXPORT GridCoord1D : public GridCoord {
class LIBKAMI_EXPORT GridCoord1D
: public GridCoord {
public:
/**
* @brief Constructor for one-dimensional coordinates
Expand Down Expand Up @@ -84,48 +85,69 @@ namespace kami {
*
* @returns the distance as a `double`
*/
double distance(std::shared_ptr<Coord> &p) const override;
double distance(std::shared_ptr<Coord>& p) const override;

/**
* @brief Test if two coordinates are equal
*/
friend bool operator==(const GridCoord1D &lhs, const GridCoord1D &rhs);
friend bool operator==(
const GridCoord1D& lhs,
const GridCoord1D& rhs
);

/**
* @brief Test if two coordinates are not equal
*/
friend bool operator!=(const GridCoord1D &lhs, const GridCoord1D &rhs);
friend bool operator!=(
const GridCoord1D& lhs,
const GridCoord1D& rhs
);

/**
* @brief Output a given coordinate to the specified stream
*/
friend std::ostream &operator<<(std::ostream &lhs, const GridCoord1D &rhs);
friend std::ostream& operator<<(
std::ostream& lhs,
const GridCoord1D& rhs
);

/**
* @brief Add two coordinates together
*/
inline friend GridCoord1D operator+(const GridCoord1D &lhs, const GridCoord1D &rhs);
inline friend GridCoord1D operator+(
const GridCoord1D& lhs,
const GridCoord1D& rhs
);

/**
* @brief Subtract one coordinate from another
*/
inline friend GridCoord1D operator-(const GridCoord1D &lhs, const GridCoord1D &rhs);
inline friend GridCoord1D operator-(
const GridCoord1D& lhs,
const GridCoord1D& rhs
);

/**
* @brief Multiply a coordinate by a scalar
*
* @details If any component of the resulting value is not a whole number, it is
* truncated following the same rules as `int`.
*/
inline friend GridCoord1D operator*(const GridCoord1D &lhs, double rhs);
inline friend GridCoord1D operator*(
const GridCoord1D& lhs,
double rhs
);

/**
* @brief Multiply a coordinate by a scalar
*
* @details If any component of the resulting value is not a whole number, it is
* truncated following the same rules as `int`.
*/
inline friend GridCoord1D operator*(double lhs, const GridCoord1D &rhs);
inline friend GridCoord1D operator*(
double lhs,
const GridCoord1D& rhs
);

private:
int _x_coord;
Expand All @@ -139,15 +161,19 @@ namespace kami {
* @see `MultiGrid1D`
* @see `SoloGrid1D`
*/
class LIBKAMI_EXPORT Grid1D : public GridDomain {
class LIBKAMI_EXPORT Grid1D
: public GridDomain {
public:
/**
* @brief Constructor
*
* @param[in] maximum_x the length of the grid.
* @param[in] wrap_x should the grid wrap around on itself.
*/
explicit Grid1D(unsigned int maximum_x, bool wrap_x = false);
explicit Grid1D(
unsigned int maximum_x,
bool wrap_x = false
);

/**
* @brief Place agent on the grid at the specified location.
Expand All @@ -158,7 +184,10 @@ namespace kami {
* @returns false if the agent is not placed at the specified
* location, otherwise, true.
*/
virtual AgentID add_agent(AgentID agent_id, const GridCoord1D &coord) = 0;
virtual AgentID add_agent(
AgentID agent_id,
const GridCoord1D& coord
) = 0;

/**
* @brief Remove agent from the grid.
Expand All @@ -177,15 +206,21 @@ namespace kami {
*
* @returns the `AgentID` of the `Agent` deleted
*/
AgentID delete_agent(AgentID agent_id, const GridCoord1D &coord);
AgentID delete_agent(
AgentID agent_id,
const GridCoord1D& coord
);

/**
* @brief Move an agent to the specified location.
*
* @param[in] agent_id the `AgentID` of the agent to move.
* @param[in] coord the coordinates of the agent.
*/
AgentID move_agent(AgentID agent_id, const GridCoord1D &coord);
AgentID move_agent(
AgentID agent_id,
const GridCoord1D& coord
);

/**
* @brief Inquire if the specified location is empty.
Expand Down Expand Up @@ -213,7 +248,7 @@ namespace kami {
*
* @return the location of the specified `Agent`
*/
[[nodiscard]] GridCoord1D get_location_by_agent(const AgentID &agent_id) const;
[[nodiscard]] GridCoord1D get_location_by_agent(const AgentID& agent_id) const;

/**
* @brief Get the contents of the specified location.
Expand All @@ -226,7 +261,7 @@ namespace kami {
* should not be deleted when no longer used.
*/
[[nodiscard]] std::shared_ptr<std::set<AgentID>>
get_location_contents(const GridCoord1D &coord) const;
get_location_contents(const GridCoord1D& coord) const;

/**
* @brief Inquire to whether the grid wraps in the `x` dimension.
Expand All @@ -246,7 +281,10 @@ namespace kami {
* for all adjacent points.
*/
[[nodiscard]] std::shared_ptr<std::unordered_set<GridCoord1D>>
get_neighborhood(AgentID agent_id, bool include_center) const;
get_neighborhood(
AgentID agent_id,
bool include_center
) const;

/**
* @brief Return the neighborhood of the specified location
Expand All @@ -259,7 +297,10 @@ namespace kami {
* for all adjacent points.
*/
[[nodiscard]] std::shared_ptr<std::unordered_set<GridCoord1D>>
get_neighborhood(const GridCoord1D &coord, bool include_center) const;
get_neighborhood(
const GridCoord1D& coord,
bool include_center
) const;

/**
* @brief Get the size of the grid in the `x` dimension.
Expand Down Expand Up @@ -298,7 +339,7 @@ namespace kami {
*
* @return the adjusted coordinate wrapped if appropriate.
*/
[[nodiscard]] GridCoord1D coord_wrap(const GridCoord1D &coord) const;
[[nodiscard]] GridCoord1D coord_wrap(const GridCoord1D& coord) const;

private:
unsigned int _maximum_x;
Expand All @@ -312,7 +353,7 @@ namespace kami {
namespace std {
template<>
struct hash<kami::GridCoord1D> {
size_t operator()(const kami::GridCoord1D &key) const {
size_t operator()(const kami::GridCoord1D& key) const {
return (hash<int>()(key.x()));
}
};
Expand Down
Loading

0 comments on commit 431a4ac

Please sign in to comment.