Skip to content

Commit

Permalink
Merge branch 'main' into chiphogg/cmake-ci#304
Browse files Browse the repository at this point in the history
  • Loading branch information
chiphogg committed Oct 28, 2024
2 parents 6f04043 + 654f1d9 commit 52053b0
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 70 deletions.
24 changes: 22 additions & 2 deletions au/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ cc_test(
],
)

cc_library(
name = "fwd",
hdrs = ["code/au/fwd.hh"],
includes = ["code"],
visibility = ["//visibility:public"],
)

cc_library(
name = "io",
hdrs = ["code/au/io.hh"],
Expand Down Expand Up @@ -208,6 +215,7 @@ cc_library(
hdrs = ["code/au/constant.hh"],
includes = ["code"],
deps = [
":fwd",
":quantity",
":unit_of_measure",
":wrapper_operations",
Expand Down Expand Up @@ -254,6 +262,7 @@ cc_library(
hdrs = ["code/au/dimension.hh"],
includes = ["code"],
deps = [
":fwd",
":packs",
":power_aliases",
],
Expand All @@ -276,6 +285,7 @@ cc_library(
hdrs = ["code/au/magnitude.hh"],
includes = ["code"],
deps = [
":fwd",
":packs",
":power_aliases",
":stdx",
Expand Down Expand Up @@ -389,6 +399,7 @@ cc_library(
hdrs = ["code/au/prefix.hh"],
includes = ["code"],
deps = [
":fwd",
":quantity",
":quantity_point",
":unit_of_measure",
Expand All @@ -414,6 +425,7 @@ cc_library(
deps = [
":apply_magnitude",
":conversion_policy",
":fwd",
":operators",
":rep",
":unit_of_measure",
Expand Down Expand Up @@ -443,6 +455,7 @@ cc_library(
hdrs = ["code/au/quantity_point.hh"],
includes = ["code"],
deps = [
":fwd",
":quantity",
":stdx",
":utility",
Expand All @@ -465,7 +478,10 @@ cc_library(
name = "rep",
hdrs = ["code/au/rep.hh"],
includes = ["code"],
deps = [":stdx"],
deps = [
":fwd",
":stdx",
],
)

cc_test(
Expand Down Expand Up @@ -540,7 +556,10 @@ cc_library(
name = "unit_symbol",
hdrs = ["code/au/unit_symbol.hh"],
includes = ["code"],
deps = [":wrapper_operations"],
deps = [
":fwd",
":wrapper_operations",
],
)

cc_test(
Expand Down Expand Up @@ -598,6 +617,7 @@ cc_library(
name = "zero",
hdrs = ["code/au/zero.hh"],
includes = ["code"],
deps = [":fwd"],
)

cc_test(
Expand Down
1 change: 1 addition & 0 deletions au/code/au/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ header_only_library(
constant.hh
conversion_policy.hh
dimension.hh
fwd.hh
io.hh
magnitude.hh
math.hh
Expand Down
1 change: 1 addition & 0 deletions au/code/au/constant.hh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#pragma once

#include "au/fwd.hh"
#include "au/quantity.hh"
#include "au/quantity_point.hh"
#include "au/stdx/type_traits.hh"
Expand Down
1 change: 1 addition & 0 deletions au/code/au/dimension.hh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#pragma once

#include "au/fwd.hh"
#include "au/packs.hh"
#include "au/power_aliases.hh"

Expand Down
168 changes: 168 additions & 0 deletions au/code/au/fwd.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
// Copyright 2024 Aurora Operations, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <cstdint>

namespace au {

struct Zero;

template <typename... BPs>
struct Dimension;

template <typename... BPs>
struct Magnitude;

template <typename UnitT>
struct QuantityMaker;

template <typename Unit>
struct SingularNameFor;

template <typename UnitT>
struct QuantityPointMaker;

template <typename UnitT, typename RepT>
class Quantity;

//
// Quantity aliases to set a particular Rep.
//
// This presents a less cumbersome interface for end users.
//
template <typename UnitT>
using QuantityD = Quantity<UnitT, double>;
template <typename UnitT>
using QuantityF = Quantity<UnitT, float>;
template <typename UnitT>
using QuantityI = Quantity<UnitT, int>;
template <typename UnitT>
using QuantityU = Quantity<UnitT, unsigned int>;
template <typename UnitT>
using QuantityI32 = Quantity<UnitT, int32_t>;
template <typename UnitT>
using QuantityU32 = Quantity<UnitT, uint32_t>;
template <typename UnitT>
using QuantityI64 = Quantity<UnitT, int64_t>;
template <typename UnitT>
using QuantityU64 = Quantity<UnitT, uint64_t>;

template <typename T>
struct CorrespondingQuantity;

template <typename UnitT, typename RepT>
class QuantityPoint;

//
// QuantityPoint aliases to set a particular Rep.
//
// This presents a less cumbersome interface for end users.
//
template <typename UnitT>
using QuantityPointD = QuantityPoint<UnitT, double>;
template <typename UnitT>
using QuantityPointF = QuantityPoint<UnitT, float>;
template <typename UnitT>
using QuantityPointI = QuantityPoint<UnitT, int>;
template <typename UnitT>
using QuantityPointU = QuantityPoint<UnitT, unsigned int>;
template <typename UnitT>
using QuantityPointI32 = QuantityPoint<UnitT, int32_t>;
template <typename UnitT>
using QuantityPointU32 = QuantityPoint<UnitT, uint32_t>;
template <typename UnitT>
using QuantityPointI64 = QuantityPoint<UnitT, int64_t>;
template <typename UnitT>
using QuantityPointU64 = QuantityPoint<UnitT, uint64_t>;

template <typename Unit>
struct Constant;

template <typename Unit>
struct SymbolFor;

template <template <class U> class Prefix>
struct PrefixApplier;

// SI Prefixes.
template <typename U>
struct Quetta;
template <typename U>
struct Ronna;
template <typename U>
struct Yotta;
template <typename U>
struct Zetta;
template <typename U>
struct Exa;
template <typename U>
struct Peta;
template <typename U>
struct Tera;
template <typename U>
struct Giga;
template <typename U>
struct Mega;
template <typename U>
struct Kilo;
template <typename U>
struct Hecto;
template <typename U>
struct Deka;
template <typename U>
struct Deci;
template <typename U>
struct Centi;
template <typename U>
struct Milli;
template <typename U>
struct Micro;
template <typename U>
struct Nano;
template <typename U>
struct Pico;
template <typename U>
struct Femto;
template <typename U>
struct Atto;
template <typename U>
struct Zepto;
template <typename U>
struct Yocto;
template <typename U>
struct Ronto;
template <typename U>
struct Quecto;

// Binary Prefixes.
template <typename U>
struct Yobi;
template <typename U>
struct Zebi;
template <typename U>
struct Exbi;
template <typename U>
struct Pebi;
template <typename U>
struct Tebi;
template <typename U>
struct Gibi;
template <typename U>
struct Mebi;
template <typename U>
struct Kibi;

} // namespace au
1 change: 1 addition & 0 deletions au/code/au/magnitude.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <limits>
#include <utility>

#include "au/fwd.hh"
#include "au/packs.hh"
#include "au/power_aliases.hh"
#include "au/stdx/utility.hh"
Expand Down
1 change: 1 addition & 0 deletions au/code/au/prefix.hh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#pragma once

#include "au/fwd.hh"
#include "au/quantity.hh"
#include "au/quantity_point.hh"
#include "au/unit_of_measure.hh"
Expand Down
34 changes: 1 addition & 33 deletions au/code/au/quantity.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "au/apply_magnitude.hh"
#include "au/conversion_policy.hh"
#include "au/fwd.hh"
#include "au/operators.hh"
#include "au/rep.hh"
#include "au/stdx/functional.hh"
Expand All @@ -27,12 +28,6 @@

namespace au {

template <typename UnitT>
struct QuantityMaker;

template <typename UnitT, typename RepT>
class Quantity;

//
// Make a Quantity of the given Unit, which has this value as measured in the Unit.
//
Expand Down Expand Up @@ -462,33 +457,6 @@ constexpr auto rep_cast(Zero z) {
return z;
}

//
// Quantity aliases to set a particular Rep.
//
// This presents a less cumbersome interface for end users.
//
template <typename UnitT>
using QuantityD = Quantity<UnitT, double>;
template <typename UnitT>
using QuantityF = Quantity<UnitT, float>;
template <typename UnitT>
using QuantityI = Quantity<UnitT, int>;
template <typename UnitT>
using QuantityU = Quantity<UnitT, unsigned int>;
template <typename UnitT>
using QuantityI32 = Quantity<UnitT, int32_t>;
template <typename UnitT>
using QuantityU32 = Quantity<UnitT, uint32_t>;
template <typename UnitT>
using QuantityI64 = Quantity<UnitT, int64_t>;
template <typename UnitT>
using QuantityU64 = Quantity<UnitT, uint64_t>;

// Forward declare `QuantityPoint` here, so that we can give better error messages when users try to
// make it into a quantity.
template <typename U, typename R>
class QuantityPoint;

template <typename UnitT>
struct QuantityMaker {
using Unit = UnitT;
Expand Down
Loading

0 comments on commit 52053b0

Please sign in to comment.