Commit 635177d5 authored by Morten Ofstad's avatar Morten Ofstad
Browse files

Moved MetadataKey/MetadataContainer to its own header file and renamed from...

Moved MetadataKey/MetadataContainer to its own header file and renamed from VDSMetaData to Metadata. Added metadata container argument to create method.
parent 08226757
......@@ -39,7 +39,7 @@ VDSHandle *open(const OpenOptions &options, Error &error)
return ret.release();
}
VDSHandle* create(const OpenOptions& options, VolumeDataLayoutDescriptor const &layoutDescriptor, std::vector<VolumeDataAxisDescriptor> const &axisDescriptors, std::vector<VolumeDataChannelDescriptor> const &channelDescriptors, Error &error)
VDSHandle* create(const OpenOptions& options, VolumeDataLayoutDescriptor const &layoutDescriptor, std::vector<VolumeDataAxisDescriptor> const &axisDescriptors, std::vector<VolumeDataChannelDescriptor> const &channelDescriptors, MetadataContainer const &metadataContainer, Error &error)
{
std::unique_ptr<VDSHandle> ret(new VDSHandle());
if (!serializeAndUploadVDSJson(options, *ret.get(), error))
......
/****************************************************************************
** Copyright 2019 The Open Group
** Copyright 2019 Bluware, Inc.
**
** 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 OPENVDS_METADATA_H
#define OPENVDS_METADATA_H
#include <unordered_map>
#include <Math/Vector.h>
namespace OpenVDS
{
struct MetadataKey
{
std::string category;
std::string name;
};
inline bool operator==(const MetadataKey& a, const MetadataKey& b) { return a.category == b.category && a.name == b.name; }
} // end namespace OpenVDS
namespace std
{
template<>
struct hash<OpenVDS::MetadataKey>
{
std::size_t operator()(const OpenVDS::MetadataKey &k) const
{
size_t const h1= std::hash<std::string>()(k.category);
size_t const h2= std::hash<std::string>()(k.name);
return h1 ^ (h2 << 1);
}
};
} // end namespace std
namespace OpenVDS
{
struct MetadataContainer
{
std::unordered_map<MetadataKey, int> intData;
std::unordered_map<MetadataKey, IntVec2> intVec2Data;
std::unordered_map<MetadataKey, IntVec3> intVec3Data;
std::unordered_map<MetadataKey, IntVec4> intVec4Data;
std::unordered_map<MetadataKey, float> floatData;
std::unordered_map<MetadataKey, FloatVec2> floatVec2Data;
std::unordered_map<MetadataKey, FloatVec3> floatVec3Data;
std::unordered_map<MetadataKey, FloatVec4> floatVec4Data;
std::unordered_map<MetadataKey, double> doubleData;
std::unordered_map<MetadataKey, DoubleVec2> doubleVec2Data;
std::unordered_map<MetadataKey, DoubleVec3> doubleVec3Data;
std::unordered_map<MetadataKey, DoubleVec4> doubleVec4Data;
std::unordered_map<MetadataKey, std::string> stringData;
std::unordered_map<MetadataKey, std::vector<uint8_t>> blobData;
};
} // end namespace OpenVDS
#endif // OPENVDS_METADATA_H
......@@ -19,6 +19,7 @@
#define OPENVDS_H
#include "openvds_export.h"
#include "Metadata.h"
#include "VolumeData.h"
#include <cstdint>
......@@ -49,8 +50,8 @@ class VolumeDataLayout;
class VolumeDataPageAccessor;
OPENVDS_EXPORT VDSHandle* open(const OpenOptions& options, Error &error);
OPENVDS_EXPORT VDSHandle* create(const OpenOptions& options, VolumeDataLayoutDescriptor const &layoutDescriptor, std::vector<VolumeDataAxisDescriptor> const &axisDescriptors, std::vector<VolumeDataChannelDescriptor> const &channelDescriptors, Error &error);
OPENVDS_EXPORT void destroy(VDSHandle *handle);
OPENVDS_EXPORT VDSHandle* create(const OpenOptions& options, VolumeDataLayoutDescriptor const &layoutDescriptor, std::vector<VolumeDataAxisDescriptor> const &axisDescriptors, std::vector<VolumeDataChannelDescriptor> const &channelDescriptors, MetadataContainer const &metadataContainer, Error &error);
OPENVDS_EXPORT void destroy(VDSHandle *handle);
OPENVDS_EXPORT VolumeDataPageAccessor *createVolumeDataPageAccessor(VolumeDataLayout *layout, DimensionsND dimension, int lod, int channel, int maxPages);
}
......
......@@ -18,6 +18,7 @@
#ifndef OPENVDSHANDLE_H
#define OPENVDSHANDLE_H
#include <OpenVDS/Metadata.h>
#include <VDS/VolumeDataLayoutDescriptor.h>
#include <VDS/VolumeDataAxisDescriptor.h>
#include <VDS/VolumeDataChannelDescriptor.h>
......@@ -32,64 +33,32 @@
namespace OpenVDS
{
struct VDSMetaDataKey
{
std::string category;
std::string name;
};
inline bool operator==(const VDSMetaDataKey& a, const VDSMetaDataKey& b)
{
return a.category == b.category
&& a.name == b.name;
}
}
namespace std
{
template<>
struct hash<OpenVDS::VDSMetaDataKey>
struct VDSHandle
{
std::size_t operator()(const OpenVDS::VDSMetaDataKey &k) const
{
size_t const h1= std::hash<std::string>()(k.category);
size_t const h2= std::hash<std::string>()(k.name);
return h1 ^ (h2 << 1);
}
};
}
std::string url;
namespace OpenVDS
{
struct VDSMetaContainer
{
std::unordered_map<VDSMetaDataKey, int> intData;
std::unordered_map<VDSMetaDataKey, IntVec2> intVec2Data;
std::unordered_map<VDSMetaDataKey, IntVec3> intVec3Data;
std::unordered_map<VDSMetaDataKey, IntVec4> intVec4Data;
std::unordered_map<VDSMetaDataKey, float> floatData;
std::unordered_map<VDSMetaDataKey, FloatVec2> floatVec2Data;
std::unordered_map<VDSMetaDataKey, FloatVec3> floatVec3Data;
std::unordered_map<VDSMetaDataKey, FloatVec4> floatVec4Data;
std::unordered_map<VDSMetaDataKey, double> doubleData;
std::unordered_map<VDSMetaDataKey, DoubleVec2> doubleVec2Data;
std::unordered_map<VDSMetaDataKey, DoubleVec3> doubleVec3Data;
std::unordered_map<VDSMetaDataKey, DoubleVec4> doubleVec4Data;
std::unordered_map<VDSMetaDataKey, std::string> stringData;
std::unordered_map<VDSMetaDataKey, std::vector<uint8_t>> blobData;
};
VolumeDataLayoutDescriptor
layoutDescriptor;
struct VDSHandle
{
std::string url;
VolumeDataLayoutDescriptor layoutDescriptor;
std::vector<VolumeDataAxisDescriptor> axisDescriptors;
std::vector<VolumeDataChannelDescriptor> channelDescriptors;
std::vector<std::unique_ptr<char[]>> descriptorStrings;
std::vector<VolumeDataLayer::ProduceStatus> produceStatuses;
VDSMetaContainer metaDataContainer;
std::vector<VolumeDataAxisDescriptor>
axisDescriptors;
std::unique_ptr<VolumeDataLayout> volumeDataLayout;
std::vector<VolumeDataChannelDescriptor>
channelDescriptors;
std::vector<std::unique_ptr<char[]>>
descriptorStrings;
std::vector<VolumeDataLayer::ProduceStatus>
produceStatuses;
MetadataContainer metaDataContainer;
std::unique_ptr<VolumeDataLayout>
volumeDataLayout;
};
}
#endif //OPENVDSHANDLE_H
......@@ -480,10 +480,15 @@ main(int argc, char *argv[])
std::vector<OpenVDS::VolumeDataChannelDescriptor> channelDescriptors = createChannelDescriptors(fileInfo, valueRange);
// Create metadata
OpenVDS::MetadataContainer
metadataContainer;
OpenVDS::Error
createError;
auto vds = OpenVDS::create(OpenVDS::OpenOptions(), layoutDescriptor, axisDescriptors, channelDescriptors, createError);
auto vds = OpenVDS::create(OpenVDS::OpenOptions(), layoutDescriptor, axisDescriptors, channelDescriptors, metadataContainer, createError);
return EXIT_SUCCESS;
}
......@@ -30,14 +30,13 @@ namespace OpenVDS
class Base64Table
{
static unsigned char table[256];
static const char alphabet[65];
static unsigned char table[256];
static Base64Table instance;
Base64Table()
{
static const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
memset(table, -1, sizeof(table));
for(int i = 0; i < sizeof(alphabet) - 1; i++)
......@@ -47,12 +46,16 @@ class Base64Table
}
public:
static int decode(char a) { return table[a]; }
static int decode(char a) { return table[(unsigned char)a]; }
static char encode(unsigned char u) { return alphabet[u]; }
};
Base64Table
Base64Table::instance;
const char
Base64Table::alphabet[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
unsigned char
Base64Table::table[256];
......@@ -447,7 +450,7 @@ static bool parseVDSObject(const std::string &json, VDSHandle &handle, Error &er
for (const Json::Value &metadata : root["MetadataList"])
{
VDSMetaDataKey key = { metadata["Category"].asString(), metadata["Name"].asString() };
MetadataKey key = { metadata["Category"].asString(), metadata["Name"].asString() };
if (metadata["Type"].asString() == "Int")
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment