-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compression factory stubs (#311)
* Add compression factory stubs Signed-off-by: Anas Abou Allaban <aabouallaban@pm.me>
- Loading branch information
Anas Abou Allaban
committed
Mar 6, 2020
1 parent
fafbe76
commit e79efb0
Showing
4 changed files
with
159 additions
and
0 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
67 changes: 67 additions & 0 deletions
67
rosbag2_compression/include/rosbag2_compression/compression_factory.hpp
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,67 @@ | ||
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// | ||
// 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. | ||
|
||
#ifndef ROSBAG2_COMPRESSION__COMPRESSION_FACTORY_HPP_ | ||
#define ROSBAG2_COMPRESSION__COMPRESSION_FACTORY_HPP_ | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "base_compressor_interface.hpp" | ||
#include "base_decompressor_interface.hpp" | ||
#include "compression_options.hpp" | ||
#include "visibility_control.hpp" | ||
|
||
namespace rosbag2_compression | ||
{ | ||
|
||
/** | ||
* Implementation of CompressionFactory. | ||
* This class implements methods for creating instances of a BaseCompressionInterface and | ||
* BaseDecompressionInterface. | ||
* This class should only be used by CompressionFactory. | ||
*/ | ||
class CompressionFactoryImpl; | ||
|
||
class ROSBAG2_COMPRESSION_PUBLIC CompressionFactory | ||
{ | ||
public: | ||
CompressionFactory(); | ||
~CompressionFactory(); | ||
|
||
/** | ||
* Create a compressor based on the specified compression format. | ||
* | ||
* \param compression_format The compression format as a string. | ||
* \return A unique pointer to the newly created compressor. | ||
*/ | ||
std::unique_ptr<rosbag2_compression::BaseCompressorInterface> | ||
create_compressor(const std::string & compression_format); | ||
|
||
/** | ||
* Create a decompressor based on the specified compression format. | ||
* | ||
* \param compression_format The compression format as a string. | ||
* \return A unique pointer to the newly created decompressor. | ||
*/ | ||
std::unique_ptr<rosbag2_compression::BaseDecompressorInterface> | ||
create_decompressor(const std::string & compression_format); | ||
|
||
private: | ||
std::unique_ptr<CompressionFactoryImpl> impl_; | ||
}; | ||
|
||
} // namespace rosbag2_compression | ||
|
||
#endif // ROSBAG2_COMPRESSION__COMPRESSION_FACTORY_HPP_ |
42 changes: 42 additions & 0 deletions
42
rosbag2_compression/src/rosbag2_compression/compression_factory.cpp
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,42 @@ | ||
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// | ||
// 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 <memory> | ||
#include <string> | ||
|
||
#include "rosbag2_compression/compression_factory.hpp" | ||
|
||
#include "compression_factory_impl.hpp" | ||
|
||
namespace rosbag2_compression | ||
{ | ||
|
||
CompressionFactory::CompressionFactory() | ||
: impl_(new CompressionFactoryImpl()) {} | ||
|
||
CompressionFactory::~CompressionFactory() = default; | ||
|
||
std::unique_ptr<rosbag2_compression::BaseCompressorInterface> | ||
CompressionFactory::create_compressor(const std::string & compression_format) | ||
{ | ||
return impl_->create_compressor(compression_format); | ||
} | ||
|
||
std::unique_ptr<rosbag2_compression::BaseDecompressorInterface> | ||
CompressionFactory::create_decompressor(const std::string & compression_format) | ||
{ | ||
return impl_->create_decompressor(compression_format); | ||
} | ||
|
||
} // namespace rosbag2_compression |
49 changes: 49 additions & 0 deletions
49
rosbag2_compression/src/rosbag2_compression/compression_factory_impl.hpp
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,49 @@ | ||
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// | ||
// 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. | ||
|
||
#ifndef ROSBAG2_COMPRESSION__COMPRESSION_FACTORY_IMPL_HPP_ | ||
#define ROSBAG2_COMPRESSION__COMPRESSION_FACTORY_IMPL_HPP_ | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "rosbag2_compression/compression_factory.hpp" | ||
|
||
namespace rosbag2_compression | ||
{ | ||
|
||
/// Implementation of the CompressionFactory. See CompressionFactory for documentation. | ||
class CompressionFactoryImpl | ||
{ | ||
public: | ||
CompressionFactoryImpl() = default; | ||
~CompressionFactoryImpl() = default; | ||
|
||
/// See CompressionFactory::create_compressor for documentation. | ||
std::unique_ptr<rosbag2_compression::BaseCompressorInterface> | ||
create_compressor(const std::string &) | ||
{ | ||
throw std::logic_error{"Not implemented"}; | ||
} | ||
|
||
/// See CompressionFactory::create_decompressor for documentation. | ||
std::unique_ptr<rosbag2_compression::BaseDecompressorInterface> | ||
create_decompressor(const std::string &) | ||
{ | ||
throw std::logic_error{"Not implemented"}; | ||
} | ||
}; | ||
} // namespace rosbag2_compression | ||
|
||
#endif // ROSBAG2_COMPRESSION__COMPRESSION_FACTORY_IMPL_HPP_ |