From 70b90bec01ea88e7513ad62da36942bee9a2350e Mon Sep 17 00:00:00 2001 From: "James P. Howard, II" Date: Sat, 17 Apr 2021 22:58:59 -0400 Subject: [PATCH] New documentation for Coord, Domain, and output function for Coord --- include/kami/domain.h | 20 +++++++++++++++++++- src/libkami/CMakeLists.txt | 1 + src/libkami/domain.cc | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/libkami/domain.cc diff --git a/include/kami/domain.h b/include/kami/domain.h index 01784b2..2306268 100644 --- a/include/kami/domain.h +++ b/include/kami/domain.h @@ -34,12 +34,30 @@ namespace kami { -/// \brief Provides an environment for the agents to participate in +/** + * Provides an environment for the agents to participate in. Implementations + * of virtual environments are expected to subclass Domain. + */ class LIBKAMI_EXPORT Domain {}; +/** + * Provides a coordinate system for each Domain. The coordinate system must + * be able to produce a human-readable version of the coordinates given. For + * instance, an integer grid in two dimensions would provide standard Descartes + * coordinates like (0, 0) for the origin, or (2, 3) for the position that is + * two units "up" and three units to the "right" of the origin. + */ class LIBKAMI_EXPORT Coord { public: + /** + * Convert the coordinate to a human readable string. + */ virtual std::string to_string() const = 0; + + /** + * Output an Coord to the specified output stream. + */ + friend std::ostream &operator<<(std::ostream &lhs, const Coord &rhs); }; } // namespace kami diff --git a/src/libkami/CMakeLists.txt b/src/libkami/CMakeLists.txt index 1eb8d1f..bc0010c 100644 --- a/src/libkami/CMakeLists.txt +++ b/src/libkami/CMakeLists.txt @@ -9,6 +9,7 @@ create_library(NAME libkami NAMESPACE libkami SOURCES agent.cc + domain.cc grid1d.cc grid2d.cc grid3d.cc diff --git a/src/libkami/domain.cc b/src/libkami/domain.cc new file mode 100644 index 0000000..132108b --- /dev/null +++ b/src/libkami/domain.cc @@ -0,0 +1,37 @@ +/*- + * Copyright (c) 2020 The Johns Hopkins University Applied Physics + * Laboratory LLC + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include + +#include +#include + +namespace kami { + +std::ostream &operator<<(std::ostream &lhs, const Coord &rhs) { + return lhs << rhs.to_string(); +} + +} // namespace kami