Skip to content

Commit

Permalink
drop config printing registry call (#9)
Browse files Browse the repository at this point in the history
* drop config printing registry call

* drop globals

* drop missing header

* revert file so that downstream projects don't break

* readd function for downstream dependencies that use it

---------

Co-authored-by: Nathan Hughes <[email protected]>
  • Loading branch information
nathanhhughes and nathanhhughes committed Mar 22, 2024
1 parent 51feae3 commit 799ca77
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 275 deletions.
1 change: 0 additions & 1 deletion config_utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ add_library(
src/asl_formatter.cpp
src/conversions.cpp
src/formatter.cpp
src/globals.cpp
src/logger.cpp
src/meta_data.cpp
src/namespacing.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include "config_utilities/config.h"
#include "config_utilities/factory.h"
#include "config_utilities/formatting/asl.h"
#include "config_utilities/globals.h"
#include "config_utilities/logging/log_to_stdout.h"
#include "config_utilities/printing.h"
#include "config_utilities/settings.h"
Expand Down
78 changes: 3 additions & 75 deletions config_utilities/include/config_utilities/globals.h
Original file line number Diff line number Diff line change
@@ -1,81 +1,9 @@
/** -----------------------------------------------------------------------------
* Copyright (c) 2023 Massachusetts Institute of Technology.
* All Rights Reserved.
*
* AUTHORS: Lukas Schmid <[email protected]>, Nathan Hughes <[email protected]>
* AFFILIATION: MIT-SPARK Lab, Massachusetts Institute of Technology
* YEAR: 2023
* LICENSE: BSD 3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* -------------------------------------------------------------------------- */

#pragma once

#include <string>
#include <vector>
#include <exception>

#include "config_utilities/internal/meta_data.h"
// TODO(nathan) drop once dependencies don't include this

namespace config {

namespace internal {

/**
* @brief Global globals for how config_utilities-based configs behave. These
* can be dynamically set and changed throughout a program.
*/
struct Globals {
Globals(const Globals& other) = delete;
Globals(const Globals&& other) = delete;
Globals& operator=(const Globals& other) = delete;
Globals& operator=(const Globals&& other) = delete;

// Singleton access to the global globals.
static Globals& instance() {
static Globals globals;
return globals;
}

// Keep track of all configs that were checked valid (as a proxy for all configs that were created).
std::vector<MetaData> valid_configs;

private:
Globals() = default;
};

} // namespace internal

// Access function in regular namespace.

/**
* @brief Return a printed string of all configs that were checked valid (as a proxy for all configs that were created).
* @param clear If true, clear the list of valid configs after printing.
* @returns The formatted string of all validated configs so far.
*/
std::string printAllValidConfigs(bool clear = false);

std::string printAllValidConfigs(bool flag) { throw std::runtime_error("deprecated"); }
} // namespace config
7 changes: 1 addition & 6 deletions config_utilities/include/config_utilities/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include <string>
#include <vector>

#include "config_utilities/globals.h"
#include "config_utilities/internal/formatter.h"
#include "config_utilities/internal/logger.h"
#include "config_utilities/internal/visitor.h"
Expand Down Expand Up @@ -93,14 +92,10 @@ const ConfigT& checkValid(const ConfigT& config) {
"for your struct.");
internal::MetaData data = internal::Visitor::getChecks(config);

// Write the config data to global storage for later summarization if requested.
if (internal::hasNoInvalidChecks(data)) {
if (Settings().store_valid_configs) {
internal::Globals::instance().valid_configs.emplace_back(internal::Visitor::getValues(config));
}

return config;
}

internal::Logger::logFatal(internal::Formatter::formatErrors(data, "Invalid config", internal::Severity::kFatal));
return config;
}
Expand Down
50 changes: 0 additions & 50 deletions config_utilities/src/globals.cpp

This file was deleted.

1 change: 0 additions & 1 deletion config_utilities/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ add_executable(
tests/conversions.cpp
tests/enums.cpp
tests/factory.cpp
tests/globals.cpp
tests/inheritance.cpp
tests/namespacing.cpp
tests/path.cpp
Expand Down
141 changes: 0 additions & 141 deletions config_utilities/test/tests/globals.cpp

This file was deleted.

0 comments on commit 799ca77

Please sign in to comment.