forked from carla-simulator/carla
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
164 changed files
with
9,283 additions
and
1,941 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma | ||
// de Barcelona (UAB). | ||
// | ||
// This work is licensed under the terms of the MIT license. | ||
// For a copy, see <https://opensource.org/licenses/MIT>. | ||
|
||
#pragma once | ||
|
||
#include "carla/NonCopyable.h" | ||
|
||
#include <memory> | ||
|
||
namespace carla { | ||
|
||
/// A very simple atomic shared ptr with relaxed memory order. | ||
template <typename T> | ||
class AtomicSharedPtr : private NonCopyable { | ||
public: | ||
|
||
template <typename... Args> | ||
explicit AtomicSharedPtr(Args &&... args) : _ptr(std::forward<Args>(args)...) {} | ||
|
||
void store(std::shared_ptr<T> ptr) { | ||
std::atomic_store_explicit(&_ptr, ptr, std::memory_order_relaxed); | ||
} | ||
|
||
std::shared_ptr<T> load() const { | ||
return std::atomic_load_explicit(&_ptr, std::memory_order_relaxed); | ||
} | ||
|
||
void operator=(std::shared_ptr<T> ptr) { | ||
store(std::move(ptr)); | ||
} | ||
|
||
private: | ||
|
||
std::shared_ptr<T> _ptr; | ||
}; | ||
|
||
} // namespace carla |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma | ||
// de Barcelona (UAB). | ||
// | ||
// This work is licensed under the terms of the MIT license. | ||
// For a copy, see <https://opensource.org/licenses/MIT>. | ||
|
||
#include "carla/FileSystem.h" | ||
|
||
#include <boost/filesystem/operations.hpp> | ||
|
||
namespace carla { | ||
|
||
void FileSystem::ValidateFilePath(std::string &filepath, const std::string &ext) { | ||
namespace fs = boost::filesystem; | ||
fs::path path(filepath); | ||
if (path.extension().empty() && !ext.empty()) { | ||
if (ext[0] != '.') { | ||
path += '.'; | ||
} | ||
path += ext; | ||
} | ||
fs::create_directories(path.parent_path()); | ||
filepath = path.string(); | ||
} | ||
|
||
} // namespace carla |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma | ||
// de Barcelona (UAB). | ||
// | ||
// This work is licensed under the terms of the MIT license. | ||
// For a copy, see <https://opensource.org/licenses/MIT>. | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace carla { | ||
|
||
/// Static functions for accessing the file system. | ||
/// | ||
/// @warning Using this file requires linking against boost_filesystem. | ||
class FileSystem { | ||
public: | ||
|
||
/// Convenient function to validate a path before creating a file. | ||
/// | ||
/// 1) Ensures all the parent directories are created if missing. | ||
/// 2) If @a filepath is missing the extension, @a default_extension is | ||
/// appended to the path. | ||
static void ValidateFilePath( | ||
std::string &filepath, | ||
const std::string &default_extension = ""); | ||
}; | ||
|
||
} // namespace carla |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.