-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[c++] Add
SOMAMultiscaleImage
class (#3094)
Add `SOMAMultiscaleImage` to `libtiledbsoma`.
- Loading branch information
Showing
7 changed files
with
225 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* @file soma_multiscale_image.cc | ||
* | ||
* @section LICENSE | ||
* | ||
* The MIT License | ||
* | ||
* @copyright Copyright (c) 2024 TileDB, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
* @section DESCRIPTION | ||
* | ||
* This file defines the SOMAMultiscaleImage class. | ||
*/ | ||
|
||
#include "soma_multiscale_image.h" | ||
#include "soma_collection.h" | ||
|
||
namespace tiledbsoma { | ||
using namespace tiledb; | ||
|
||
//=================================================================== | ||
//= public static | ||
//=================================================================== | ||
|
||
void SOMAMultiscaleImage::create( | ||
std::string_view uri, | ||
std::shared_ptr<SOMAContext> ctx, | ||
std::optional<TimestampRange> timestamp) { | ||
try { | ||
std::filesystem::path image_uri(uri); | ||
SOMAGroup::create( | ||
ctx, image_uri.string(), "SOMAMultiscaleImage", timestamp); | ||
} catch (TileDBError& e) { | ||
throw TileDBSOMAError(e.what()); | ||
} | ||
} | ||
|
||
std::unique_ptr<SOMAMultiscaleImage> SOMAMultiscaleImage::open( | ||
std::string_view uri, | ||
OpenMode mode, | ||
std::shared_ptr<SOMAContext> ctx, | ||
std::optional<TimestampRange> timestamp) { | ||
try { | ||
return std::make_unique<SOMAMultiscaleImage>(mode, uri, ctx, timestamp); | ||
} catch (TileDBError& e) { | ||
throw TileDBSOMAError(e.what()); | ||
} | ||
} | ||
|
||
} // namespace tiledbsoma |
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,105 @@ | ||
/** | ||
* @file soma_multiscale_image.h | ||
* | ||
* @section LICENSE | ||
* | ||
* The MIT License | ||
* | ||
* @copyright Copyright (c) 2024 TileDB, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
* @section DESCRIPTION | ||
* | ||
* This file defines the SOMAMultiscaleImage class. | ||
*/ | ||
|
||
#ifndef SOMA_MULTISCALE_IMAGE | ||
#define SOMA_MULTISCALE_IMAGE | ||
|
||
#include <tiledb/tiledb> | ||
|
||
#include "soma_collection.h" | ||
|
||
namespace tiledbsoma { | ||
|
||
using namespace tiledb; | ||
class SOMAMultiscaleImage : public SOMACollection { | ||
public: | ||
//=================================================================== | ||
//= public static | ||
//=================================================================== | ||
|
||
/** | ||
* @brief Create a SOMAMultiscaleImage object at the given URI. | ||
* | ||
* @param uri URI to create the SOMAMultiscaleImage | ||
* @param schema TileDB ArraySchema | ||
* @param platform_config Optional config parameter dictionary | ||
*/ | ||
static void create( | ||
std::string_view uri, | ||
std::shared_ptr<SOMAContext> ctx, | ||
std::optional<TimestampRange> timestamp = std::nullopt); | ||
|
||
/** | ||
* @brief Open a group at the specified URI and return SOMAMultiscaleImage | ||
* object. | ||
* | ||
* @param uri URI of the array | ||
* @param mode read or write | ||
* @param ctx TileDB context | ||
* @param timestamp Optional pair indicating timestamp start and end | ||
* @return std::shared_ptr<SOMAMultiscaleImage> SOMAMultiscaleImage | ||
*/ | ||
static std::unique_ptr<SOMAMultiscaleImage> open( | ||
std::string_view uri, | ||
OpenMode mode, | ||
std::shared_ptr<SOMAContext> ctx, | ||
std::optional<TimestampRange> timestamp = std::nullopt); | ||
|
||
//=================================================================== | ||
//= public non-static | ||
//=================================================================== | ||
|
||
SOMAMultiscaleImage( | ||
OpenMode mode, | ||
std::string_view uri, | ||
std::shared_ptr<SOMAContext> ctx, | ||
std::optional<TimestampRange> timestamp = std::nullopt) | ||
: SOMACollection(mode, uri, ctx, timestamp) { | ||
} | ||
|
||
SOMAMultiscaleImage(const SOMACollection& other) | ||
: SOMACollection(other) { | ||
} | ||
|
||
SOMAMultiscaleImage() = delete; | ||
SOMAMultiscaleImage(const SOMAMultiscaleImage&) = default; | ||
SOMAMultiscaleImage(SOMAMultiscaleImage&&) = default; | ||
~SOMAMultiscaleImage() = default; | ||
|
||
private: | ||
//=================================================================== | ||
//= private non-static | ||
//=================================================================== | ||
}; | ||
} // namespace tiledbsoma | ||
|
||
#endif // SOMA_MULTISCALE_IMAGE |
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,45 @@ | ||
/** | ||
* @file unit_soma_multiscale_image.cc | ||
* | ||
* @section LICENSE | ||
* | ||
* The MIT License | ||
* | ||
* @copyright Copyright (c) 2024 TileDB, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
* @section DESCRIPTION | ||
* | ||
* This file manages unit tests for the SOMAMultiscaleImage class | ||
*/ | ||
#include "common.h" | ||
|
||
TEST_CASE("SOMAMultiscaleImage: basic") { | ||
auto ctx = std::make_shared<SOMAContext>(); | ||
std::string uri = "mem://unit-test-multiscale-image-basic"; | ||
|
||
SOMAMultiscaleImage::create(uri, ctx, std::nullopt); | ||
auto soma_image = SOMAMultiscaleImage::open( | ||
uri, OpenMode::read, ctx, std::nullopt); | ||
REQUIRE(soma_image->uri() == uri); | ||
REQUIRE(soma_image->ctx() == ctx); | ||
REQUIRE(soma_image->type() == "SOMAMultiscaleImage"); | ||
soma_image->close(); | ||
} |