Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ign -> gz Namespace Migration : gz-utils #61

Merged
merged 22 commits into from
May 28, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ Deprecated code produces compile-time warnings. These warning serve as
notification to users that their code should be upgraded. The next major
release will remove the deprecated code.

## Ignition Utils 1.X to 2.X

* The `ignition` namespace is deprecated and will be removed in future versions.
Use `gz` instead.

* Header files under `ignition/...` are deprecated and will be removed in future versions.
Use `gz/...` instead.

## Ignition Utils 1.2 to 1.3

Recommended migration:
Expand Down
1 change: 1 addition & 0 deletions cli/include/ignition/utils/cli.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
*/

#include <gz/utils/cli.hh>
#include <ignition/utils/config.hh>
5 changes: 2 additions & 3 deletions include/gz/utils/Environment.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <string>

namespace ignition
namespace gz
{
namespace utils
{
Expand Down Expand Up @@ -68,7 +68,6 @@ bool GZ_UTILS_VISIBLE unsetenv(const std::string &_name);

}
} // namespace utils
} // namespace ignition
} // namespace gz

#endif // GZ_UTILS_ENVIRONMENT_HH_

8 changes: 4 additions & 4 deletions include/gz/utils/ImplPtr.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <gz/utils/SuppressWarning.hh>
#include <gz/utils/Export.hh>

namespace ignition
namespace gz
{
namespace utils
{
Expand Down Expand Up @@ -226,20 +226,20 @@ namespace ignition
template <class T, typename... Args>
UniqueImplPtr<T> MakeUniqueImpl(Args &&..._args);
} // namespace utils
} // namespace ignition
} // namespace gz

/// \brief Add a private ImplPtr to a class as dataPtr.
/// This variant takes a forward-declared ImplementationClass as the impl.
#define IGN_UTILS_IMPL_PTR_FWD(ImplementationClass, memberName) \
IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING \
private: ::ignition::utils::ImplPtr<ImplementationClass> memberName; \
private: ::gz::utils::ImplPtr<ImplementationClass> memberName; \
IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING

/// \brief Add a private UniqueImplPtr to a class as dataPtr.
/// This variant takes a forward-declared ImplementationClass as the impl.
#define IGN_UTILS_UNIQUE_IMPL_PTR_FWD(ImplementationClass, memberName) \
IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING \
private: ::ignition::utils::UniqueImplPtr<ImplementationClass> memberName; \
private: ::gz::utils::UniqueImplPtr<ImplementationClass> memberName; \
IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING

/// \brief Add a private ImplPtr to a class as dataPtr.
Expand Down
16 changes: 7 additions & 9 deletions include/gz/utils/NeverDestroyed.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
#include <type_traits>
#include <utility>

namespace ignition
namespace gz
{
namespace utils
{

/// Originally copied from https://github.com/RobotLocomotion/drake/blob/v0.36.0/common/never_destroyed.h
/// Originally licensed BSD 3-Clause (https://github.com/RobotLocomotion/drake/blob/v0.36.0/LICENSE.TXT)
/// Re-licensed Apache-2.0 with permission from:
/// jwnimmer-tri (https://github.com/ignitionrobotics/ign-utils/pull/31#issuecomment-989173512)
/// jwnimmer-tri (https://github.com/gazebosim/ign-utils/pull/31#issuecomment-989173512)
///
/// Wraps an underlying type T such that its storage is a direct member field
/// of this object (i.e., without any indirection into the heap), but *unlike*
Expand Down Expand Up @@ -62,11 +61,11 @@ namespace utils
///
/// static Singleton& getInstance()
/// {
/// static ignition::utils::NeverDestroyed<Singleton> instance;
/// static gz::utils::NeverDestroyed<Singleton> instance;
/// return instance.access();
/// }
/// private:
/// friend ignition::utils::NeverDestroyed<Singleton>;
/// friend gz::utils::NeverDestroyed<Singleton>;
/// Singleton() = default;
/// };
/// @endcode
Expand All @@ -78,7 +77,7 @@ namespace utils
/// Foo ParseFoo(const std::string& foo_string)
/// {
/// using Dict = std::unordered_map<std::string, Foo>;
/// static const ignition::utils::NeverDestroyed<Dict> string_to_enum
/// static const gz::utils::NeverDestroyed<Dict> string_to_enum
/// {
/// std::initializer_list<Dict::value_type>
/// {
Expand All @@ -95,7 +94,7 @@ namespace utils
/// @code
/// const std::vector<double>& GetConstantMagicNumbers()
/// {
/// static const ignition::utils::NeverDestroyed<std::vector<double>> result
/// static const gz::utils::NeverDestroyed<std::vector<double>> result
/// {
/// []()
/// {
Expand Down Expand Up @@ -155,8 +154,7 @@ class NeverDestroyed

private: typename std::aligned_storage<sizeof(T), alignof(T)>::type storage;
};

} // namespace utils
} // namespace ignition
} // namespace gz

#endif // GZ_UTILS_NEVERDESTROYED_HH_
6 changes: 1 addition & 5 deletions include/gz/utils/config.hh.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@

#define GZ_UTILS_VERSION_NAMESPACE v${PROJECT_VERSION_MAJOR}

#define GZ_UTILS_VERSION_HEADER "Ignition ${IGN_DESIGNATION}, version ${PROJECT_VERSION_FULL}\nCopyright (C) 2020 Open Source Robotics Foundation.\nReleased under the Apache 2.0 License.\n\n"

#cmakedefine IGNITION_UTILS_BUILD_TYPE_PROFILE 1
#cmakedefine IGNITION_UTILS_BUILD_TYPE_DEBUG 1
#cmakedefine IGNITION_UTILS_BUILD_TYPE_RELEASE 1
#define GZ_UTILS_VERSION_HEADER "Gazebo Utils, version ${PROJECT_VERSION_FULL}\nCopyright (C) 2020 Open Source Robotics Foundation.\nReleased under the Apache 2.0 License.\n\n"

#endif
5 changes: 2 additions & 3 deletions include/gz/utils/detail/DefaultOps.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <type_traits>

namespace ignition
namespace gz
{
namespace utils
{
Expand Down Expand Up @@ -78,7 +78,6 @@ namespace ignition
};
} // namespace detail
} // namespace utils
} // namespace ignition
} // namespace gz

#endif // GZ_UTILS__DETAIL__DEFAULTOPS_HH_

4 changes: 2 additions & 2 deletions include/gz/utils/detail/ImplPtr.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <utility>

namespace ignition
namespace gz
{
namespace utils
{
Expand Down Expand Up @@ -146,6 +146,6 @@ namespace ignition
&detail::DefaultDelete<T>);
}
} // namespace utils
} // namespace ignition
} // namespace gz

#endif // GZ_UTILS__DETAIL__IMPLPTR_HH_
1 change: 1 addition & 0 deletions include/ignition/utils/Environment.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
*/

#include <gz/utils/Environment.hh>
#include <ignition/utils/config.hh>
1 change: 1 addition & 0 deletions include/ignition/utils/Export.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
*/

#include <gz/utils/Export.hh>
#include <ignition/utils/config.hh>
1 change: 1 addition & 0 deletions include/ignition/utils/ExtraTestMacros.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
*/

#include <gz/utils/ExtraTestMacros.hh>
#include <ignition/utils/config.hh>
1 change: 1 addition & 0 deletions include/ignition/utils/ImplPtr.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
*/

#include <gz/utils/ImplPtr.hh>
#include <ignition/utils/config.hh>
1 change: 1 addition & 0 deletions include/ignition/utils/NeverDestroyed.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
*/

#include <gz/utils/NeverDestroyed.hh>
#include <ignition/utils/config.hh>
1 change: 1 addition & 0 deletions include/ignition/utils/SuppressWarning.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
*/

#include <gz/utils/SuppressWarning.hh>
#include <ignition/utils/config.hh>
18 changes: 15 additions & 3 deletions include/ignition/utils/config.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*
*/

#include <gz/utils/config.hh>
#ifndef IGNITION_UTILS__CONFIG_HH_
#define IGNITION_UTILS__CONFIG_HH_

#ifndef IGNITION_UTILS_CONFIG_HH_
#define IGNITION_UTILS_CONFIG_HH_
#include <gz/utils/config.hh>

#define IGNITION_UTILS_MAJOR_VERSION GZ_UTILS_MAJOR_VERSION
#define IGNITION_UTILS_MINOR_VERSION GZ_UTILS_MINOR_VERSION
Expand All @@ -31,4 +31,16 @@

#define IGNITION_UTILS_VERSION_HEADER GZ_UTILS_VERSION_HEADER

namespace gz
{
}

namespace ignition
{
#ifndef SUPPRESS_IGNITION_HEADER_DEPRECATION
#pragma message("ignition namespace is deprecated! Use gz instead!")
#endif
using namespace gz;
}

#endif
1 change: 1 addition & 0 deletions include/ignition/utils/detail/DefaultOps.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
*/

#include <gz/utils/detail/DefaultOps.hh>
#include <ignition/utils/config.hh>
1 change: 1 addition & 0 deletions include/ignition/utils/detail/Export.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
*/

#include <gz/utils/detail/Export.hh>
#include <ignition/utils/config.hh>
1 change: 1 addition & 0 deletions include/ignition/utils/detail/ExtraTestMacros.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
*/

#include <gz/utils/detail/ExtraTestMacros.hh>
#include <ignition/utils/config.hh>
1 change: 1 addition & 0 deletions include/ignition/utils/detail/ImplPtr.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
*/

#include <gz/utils/detail/ImplPtr.hh>
#include <ignition/utils/config.hh>
1 change: 1 addition & 0 deletions include/ignition/utils/detail/SuppressWarning.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
*/

#include <gz/utils/detail/SuppressWarning.hh>
#include <ignition/utils/config.hh>
2 changes: 1 addition & 1 deletion src/Environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <iostream>


namespace ignition
namespace gz
{
namespace utils
{
Expand Down
2 changes: 1 addition & 1 deletion src/Environment_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include <gz/utils/Environment.hh>

using namespace ignition;
using namespace gz;

/////////////////////////////////////////////////
TEST(Environment, emptyENV)
Expand Down
10 changes: 5 additions & 5 deletions src/NeverDestroyed_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ GTEST_TEST(NeverDestroyed, NoBoomTest)
try
{
{
ignition::utils::NeverDestroyed<DtorGoesBoom> foo;
gz::utils::NeverDestroyed<DtorGoesBoom> foo;
}
ASSERT_TRUE(true);
}
Expand All @@ -83,11 +83,11 @@ class Singleton
public: void operator=(Singleton &&) = delete;
public: static Singleton &getInstance()
{
static ignition::utils::NeverDestroyed<Singleton> instance;
static gz::utils::NeverDestroyed<Singleton> instance;
return instance.Access();
}

private: friend ignition::utils::NeverDestroyed<Singleton>;
private: friend gz::utils::NeverDestroyed<Singleton>;
private: Singleton() = default;
};

Expand All @@ -108,7 +108,7 @@ enum class Foo
Foo ParseFoo(const std::string &foo_string)
{
using Dict = std::unordered_map<std::string, Foo>;
static const ignition::utils::NeverDestroyed<Dict> string_to_enum{
static const gz::utils::NeverDestroyed<Dict> string_to_enum{
std::initializer_list<Dict::value_type>{
{"bar", Foo::kBar},
{"baz", Foo::kBaz},
Expand All @@ -127,7 +127,7 @@ GTEST_TEST(NeverDestroyedExample, ParseFoo)
using Result = std::vector<std::uint_fast32_t>;
const Result &GetConstantMagicNumbers()
{
static const ignition::utils::NeverDestroyed<Result> result{
static const gz::utils::NeverDestroyed<Result> result{
[]()
{
Result prototype;
Expand Down
4 changes: 2 additions & 2 deletions test/integration/all_symbols_have_version.bash.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ VERSIONED_NS=v@PROJECT_VERSION_MAJOR@
IGN_PROJECT=@IGN_DESIGNATION@

# Sanity check - there should be at least one symbol
NUM_SYMBOLS=$(nm $LIBPATH | grep -e "ignition.*$IGN_PROJECT" | wc -l)
NUM_SYMBOLS=$(nm $LIBPATH | grep -e "gz.*$IGN_PROJECT" | wc -l)

if [ $NUM_SYMBOLS -eq 0 ]
then
Expand All @@ -14,7 +14,7 @@ then
fi

# There must be no unversioned symbols
UNVERSIONED_SYMBOLS=$(nm $LIBPATH | grep -e "ignition.*$IGN_PROJECT" | grep -e "$VERSIONED_NS" -v)
UNVERSIONED_SYMBOLS=$(nm $LIBPATH | grep -e "gz.*$IGN_PROJECT" | grep -e "$VERSIONED_NS" -v)
UNVERSIONED_SYMBOL_CHARS=$(printf "$UNVERSIONED_SYMBOLS" | wc -m)

if [ $UNVERSIONED_SYMBOL_CHARS -ne 0 ]
Expand Down
34 changes: 34 additions & 0 deletions test/integration/deprecated_TEST.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2022 Open Source Robotics Foundation
*
* 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.
*
*/

#include <gtest/gtest.h>

#define SUPPRESS_IGNITION_HEADER_DEPRECATION

#include <ignition/utils/SuppressWarning.hh>
#include <ignition/utils/ImplPtr.hh>
#include <ignition/utils/NeverDestroyed.hh>

/////////////////////////////////////////////////
// Make sure the ignition namespace still works
TEST(Deprecated, IgnitionNamespace)
{
auto impl = ignition::utils::MakeImpl<int>();
ignition::utils::NeverDestroyed<int> neverDestroyed;
}

#undef SUPPRESS_IGNITION_HEADER_DEPRECATION
2 changes: 1 addition & 1 deletion test/integration/implptr/ImplPtr_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <gz/utils/ImplPtr.hh>
#include "implptr_test_classes.hh"

using namespace ignition::implptr_test_classes;
using namespace gz::implptr_test_classes;

/////////////////////////////////////////////////
TEST(ImplPtr, CopyConstruct)
Expand Down
6 changes: 3 additions & 3 deletions test/integration/implptr/implptr_test_classes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
#include <string>
#include <thread>

using namespace ignition;
using namespace ignition::implptr_test_classes;
using namespace gz;
using namespace gz::implptr_test_classes;

class ignition::implptr_test_classes::ObjectPrivate
class gz::implptr_test_classes::ObjectPrivate
{
public: void TestFunc()
{
Expand Down
Loading