Commit cbb94c87 authored by Jørgen Lind's avatar Jørgen Lind
Browse files

Move rest of code over to standard of having capital first leter

on public Function and public Members
parent 0fb2a2b2
......@@ -2,6 +2,7 @@
Builds
Dist
CMakeSettings.json
CMakeLists.txt.user
python/.eggs
python/_skbuild
python/**/*.pyd
......
......@@ -22,7 +22,7 @@
namespace OpenVDS
{
FileView * FileView::addReference(FileView *pcFileView)
FileView * FileView::AddReference(FileView *pcFileView)
{
assert(pcFileView);
......@@ -32,7 +32,7 @@ FileView * FileView::addReference(FileView *pcFileView)
return pcFileView;
}
bool FileView::removeReference(FileView *pcFileView)
bool FileView::RemoveReference(FileView *pcFileView)
{
assert(pcFileView);
assert(pcFileView->m_nReferenceCount > 0);
......@@ -55,29 +55,29 @@ File::File()
File::~File()
{
if (isOpen())
if (IsOpen())
{
close();
Close();
}
}
bool File::isWriteable() const
bool File::IsWriteable() const
{
return _isWriteable;
}
bool File::isOpen() const
bool File::IsOpen() const
{
assert(!!_pxPlatformHandle == !_cFileName.empty());
return _pxPlatformHandle;
}
std::string File::fileName() const
std::string File::FileName() const
{
return _cFileName;
}
void *File::handle() const
void *File::Handle() const
{
return _pxPlatformHandle;
}
......
......@@ -56,36 +56,36 @@ public:
class SystemFileMappingObject
{
public:
static bool open(SystemFileMappingObject** ppcFileMappingObject, File &file, IOError &error);
static void close(SystemFileMappingObject** pcFileMappingObject);
static bool Open(SystemFileMappingObject** ppcFileMappingObject, File &file, IOError &error);
static void Close(SystemFileMappingObject** pcFileMappingObject);
};
OPENVDS_EXPORT
const void * pointer() const
const void * Pointer() const
{
return m_pData;
}
OPENVDS_EXPORT
int64_t pos() const
int64_t Pos() const
{
return m_nPos;
}
OPENVDS_EXPORT
int64_t size() const
int64_t Size() const
{
return m_nSize;
}
OPENVDS_EXPORT
virtual bool prefetch(const void *pData, int64_t nSize, IOError &error) const = 0;
virtual bool Prefetch(const void *pData, int64_t nSize, IOError &error) const = 0;
OPENVDS_EXPORT
static FileView* addReference(FileView* pcFileView);
static FileView* AddReference(FileView* pcFileView);
OPENVDS_EXPORT
static bool removeReference(FileView* pcFileView);
static bool RemoveReference(FileView* pcFileView);
};
// This class is thread-safe except for the following methods:
......@@ -97,23 +97,23 @@ public:
OPENVDS_EXPORT File();
OPENVDS_EXPORT ~File();
OPENVDS_EXPORT static bool exists(const std::string& filename);
OPENVDS_EXPORT bool open(const std::string& filename, bool isCreate, bool isDestroyExisting, bool isWriteAccess, IOError& error);
OPENVDS_EXPORT void close();
OPENVDS_EXPORT static bool Exists(const std::string& filename);
OPENVDS_EXPORT bool Open(const std::string& filename, bool isCreate, bool isDestroyExisting, bool isWriteAccess, IOError& error);
OPENVDS_EXPORT void Close();
OPENVDS_EXPORT int64_t size(IOError& error) const;
OPENVDS_EXPORT int64_t Size(IOError& error) const;
OPENVDS_EXPORT bool read(void* pxData, int64_t nOffset, int32_t nLength, IOError& error) const;
OPENVDS_EXPORT bool write(const void* pxData, int64_t nOffset, int32_t nLength, IOError& error);
OPENVDS_EXPORT bool Read(void* pxData, int64_t nOffset, int32_t nLength, IOError& error) const;
OPENVDS_EXPORT bool Write(const void* pxData, int64_t nOffset, int32_t nLength, IOError& error);
OPENVDS_EXPORT bool flush();
OPENVDS_EXPORT bool isWriteable() const;
OPENVDS_EXPORT bool isOpen() const;
OPENVDS_EXPORT std::string fileName() const;
OPENVDS_EXPORT bool Flush();
OPENVDS_EXPORT bool IsWriteable() const;
OPENVDS_EXPORT bool IsOpen() const;
OPENVDS_EXPORT std::string FileName() const;
OPENVDS_EXPORT FileView *createFileView(int64_t iPos, int64_t nSize, bool isPopulate, IOError &error);
OPENVDS_EXPORT FileView *CreateFileView(int64_t iPos, int64_t nSize, bool isPopulate, IOError &error);
OPENVDS_EXPORT void *handle() const;
OPENVDS_EXPORT void *Handle() const;
private:
void* _pxPlatformHandle;
bool _isWriteable;
......
......@@ -31,13 +31,13 @@ Request::~Request()
TransferDownloadHandler::~TransferDownloadHandler()
{
}
void TransferDownloadHandler::handleMetadata(const std::string& key, const std::string& header)
void TransferDownloadHandler::HandleMetadata(const std::string& key, const std::string& header)
{
}
IOManager::~IOManager()
{}
IOManager* IOManager::createIOManager(const OpenOptions& options, Error &error)
IOManager* IOManager::CreateIOManager(const OpenOptions& options, Error &error)
{
switch(options.connectionType)
{
......
......@@ -30,9 +30,9 @@ namespace OpenVDS
{
public:
virtual ~TransferDownloadHandler();
virtual void handleMetadata(const std::string &key, const std::string &header);
virtual void handleData(std::vector<uint8_t> &&data) = 0;
virtual void completed(const Request &request, const Error &error) = 0;
virtual void HandleMetadata(const std::string &key, const std::string &header);
virtual void HandleData(std::vector<uint8_t> &&data) = 0;
virtual void Completed(const Request &request, const Error &error) = 0;
};
class Request
......@@ -40,11 +40,11 @@ namespace OpenVDS
public:
Request(const std::string &objectName);
virtual ~Request();
virtual void waitForFinish() = 0;
virtual bool isDone() const = 0;
virtual bool isSuccess(Error &error) const = 0;
virtual void cancel() = 0;
const std::string &getObjectName() const { return m_objectName; }
virtual void WaitForFinish() = 0;
virtual bool IsDone() const = 0;
virtual bool IsSuccess(Error &error) const = 0;
virtual void Cancel() = 0;
const std::string &GetObjectName() const { return m_objectName; }
private:
std::string m_objectName;
......@@ -60,19 +60,19 @@ namespace OpenVDS
{
public:
virtual ~IOManager();
virtual std::shared_ptr<Request> download(const std::string objectName, std::shared_ptr<TransferDownloadHandler> handler, const IORange &range = IORange()) = 0;
virtual std::shared_ptr<Request> upload(const std::string objectName, const std::string &contentDispostionFilename, const std::string &contentType, const std::vector<std::pair<std::string, std::string>> &metadataHeader, std::shared_ptr<std::vector<uint8_t>> data, std::function<void(const Request &request, const Error &error)> completedCallback = nullptr) = 0;
std::shared_ptr<Request> uploadBinary(const std::string objectName, const std::string &contentDispositionFilename, const std::vector<std::pair<std::string, std::string>> &metadataHeader, std::shared_ptr<std::vector<uint8_t>> data, std::function<void(const Request &request, const Error &error)> completedCallback = nullptr)
virtual std::shared_ptr<Request> Download(const std::string objectName, std::shared_ptr<TransferDownloadHandler> handler, const IORange &range = IORange()) = 0;
virtual std::shared_ptr<Request> Upload(const std::string objectName, const std::string &contentDispostionFilename, const std::string &contentType, const std::vector<std::pair<std::string, std::string>> &metadataHeader, std::shared_ptr<std::vector<uint8_t>> data, std::function<void(const Request &request, const Error &error)> completedCallback = nullptr) = 0;
std::shared_ptr<Request> UploadBinary(const std::string objectName, const std::string &contentDispositionFilename, const std::vector<std::pair<std::string, std::string>> &metadataHeader, std::shared_ptr<std::vector<uint8_t>> data, std::function<void(const Request &request, const Error &error)> completedCallback = nullptr)
{
return upload(objectName, contentDispositionFilename, "application/octet-stream", metadataHeader, data, completedCallback);
return Upload(objectName, contentDispositionFilename, "application/octet-stream", metadataHeader, data, completedCallback);
}
std::shared_ptr<Request> uploadJson(const std::string objectName, std::shared_ptr<std::vector<uint8_t>> data, std::function<void(const Request &request, const Error &error)> completedCallback = nullptr)
std::shared_ptr<Request> UploadJson(const std::string objectName, std::shared_ptr<std::vector<uint8_t>> data, std::function<void(const Request &request, const Error &error)> completedCallback = nullptr)
{
return upload(objectName, "", "application/json", std::vector<std::pair<std::string, std::string>>(), data, completedCallback);
return Upload(objectName, "", "application/json", std::vector<std::pair<std::string, std::string>>(), data, completedCallback);
}
static IOManager *createIOManager(const OpenOptions &options, Error &error);
static IOManager *CreateIOManager(const OpenOptions &options, Error &error);
};
}
......
......@@ -112,7 +112,7 @@ namespace OpenVDS
Aws::S3::Model::GetObjectResult result = const_cast<Aws::S3::Model::GetObjectOutcome&>(getObjectOutcome).GetResultWithOwnership();
for (auto it : result.GetMetadata())
{
objReq->m_handler->handleMetadata(convertAwsString(it.first), convertAwsString(it.second));
objReq->m_handler->HandleMetadata(convertAwsString(it.first), convertAwsString(it.second));
}
auto& retrieved_object = result.GetBody();
auto content_length = result.GetContentLength();
......@@ -122,7 +122,7 @@ namespace OpenVDS
{
data.resize(content_length);
retrieved_object.read((char*)&data[0], content_length);
objReq->m_handler->handleData(std::move(data));
objReq->m_handler->HandleData(std::move(data));
}
lock.lock();
}
......@@ -137,7 +137,7 @@ namespace OpenVDS
objReq->m_done = true;
objReq->m_waitForFinish.notify_all();
lock.unlock();
objReq->m_handler->completed(*objReq, objReq->m_error);
objReq->m_handler->Completed(*objReq, objReq->m_error);
}
DownloadRequestAWS::DownloadRequestAWS(const std::string& id, const std::shared_ptr<TransferDownloadHandler>& handler)
......@@ -150,14 +150,14 @@ namespace OpenVDS
DownloadRequestAWS::~DownloadRequestAWS()
{
DownloadRequestAWS::cancel();
DownloadRequestAWS::Cancel();
}
void DownloadRequestAWS::run(Aws::S3::S3Client& client, const std::string& bucket, const IORange& range, std::weak_ptr<DownloadRequestAWS> downloadRequest)
{
Aws::S3::Model::GetObjectRequest object_request;
object_request.SetBucket(convertStdString(bucket));
object_request.SetKey(convertStdString(getObjectName()));
object_request.SetKey(convertStdString(GetObjectName()));
if (range.end)
{
object_request.SetRange(convertStdString(fmt::format("bytes={}-{}", range.start, range.end)));
......@@ -169,18 +169,18 @@ namespace OpenVDS
client.GetObjectAsync(object_request, bounded_callback);
}
void DownloadRequestAWS::waitForFinish()
void DownloadRequestAWS::WaitForFinish()
{
std::unique_lock<std::mutex> lock(m_mutex);
m_waitForFinish.wait(lock, [this]{ return m_done; });
}
bool DownloadRequestAWS::isDone() const
bool DownloadRequestAWS::IsDone() const
{
std::unique_lock<std::mutex> lock(m_mutex);
return m_done;
}
bool DownloadRequestAWS::isSuccess(Error& error) const
bool DownloadRequestAWS::IsSuccess(Error& error) const
{
std::unique_lock<std::mutex> lock(m_mutex);
if (!m_done)
......@@ -193,7 +193,7 @@ namespace OpenVDS
return m_error.Code == 0;
}
void DownloadRequestAWS::cancel()
void DownloadRequestAWS::Cancel()
{
m_cancelled = true;
}
......@@ -234,7 +234,7 @@ namespace OpenVDS
Aws::S3::Model::PutObjectRequest put;
put.SetBucket(convertStdString(bucket));
put.SetKey(convertStdString(getObjectName()));
put.SetKey(convertStdString(GetObjectName()));
put.SetBody(m_stream);
put.SetContentType(convertStdString(contentType));
put.SetContentLength(data->size());
......@@ -250,17 +250,17 @@ namespace OpenVDS
}
void UploadRequestAWS::waitForFinish()
void UploadRequestAWS::WaitForFinish()
{
std::unique_lock<std::mutex> lock(m_mutex);
m_waitForFinish.wait(lock, [this]{ return this->m_done; });
}
bool UploadRequestAWS::isDone() const
bool UploadRequestAWS::IsDone() const
{
std::unique_lock<std::mutex> lock(m_mutex);
return m_done;
}
bool UploadRequestAWS::isSuccess(Error& error) const
bool UploadRequestAWS::IsSuccess(Error& error) const
{
std::unique_lock<std::mutex> lock(m_mutex);
if (!m_done)
......@@ -272,7 +272,7 @@ namespace OpenVDS
error = m_error;
return m_error.Code == 0;
}
void UploadRequestAWS::cancel()
void UploadRequestAWS::Cancel()
{
m_cancelled = true;
}
......@@ -307,7 +307,7 @@ namespace OpenVDS
deinitizlieAWSSDK();
}
std::shared_ptr<Request> IOManagerAWS::download(const std::string objectName, std::shared_ptr<TransferDownloadHandler> handler, const IORange &range)
std::shared_ptr<Request> IOManagerAWS::Download(const std::string objectName, std::shared_ptr<TransferDownloadHandler> handler, const IORange &range)
{
std::string id = objectName.empty()? m_objectId : m_objectId + "/" + objectName;
auto ret = std::make_shared<DownloadRequestAWS>(id, handler);
......@@ -315,7 +315,7 @@ namespace OpenVDS
return ret;
}
std::shared_ptr<Request> IOManagerAWS::upload(const std::string objectName, const std::string& contentDispositionFilename, const std::string& contentType, const std::vector<std::pair<std::string, std::string>>& metadataHeader, std::shared_ptr<std::vector<uint8_t>> data, std::function<void(const Request & request, const Error & error)> completedCallback)
std::shared_ptr<Request> IOManagerAWS::Upload(const std::string objectName, const std::string& contentDispositionFilename, const std::string& contentType, const std::vector<std::pair<std::string, std::string>>& metadataHeader, std::shared_ptr<std::vector<uint8_t>> data, std::function<void(const Request & request, const Error & error)> completedCallback)
{
std::string id = objectName.empty()? m_objectId : m_objectId + "/" + objectName;
auto ret = std::make_shared<UploadRequestAWS>(id, completedCallback);
......
......@@ -39,10 +39,10 @@ namespace OpenVDS
void run(Aws::S3::S3Client& client, const std::string& bucket, const IORange& range, std::weak_ptr<DownloadRequestAWS> request);
void waitForFinish() override;
bool isDone() const override;
bool isSuccess(Error &error) const override;
void cancel() override;
void WaitForFinish() override;
bool IsDone() const override;
bool IsSuccess(Error &error) const override;
void Cancel() override;
std::shared_ptr<TransferDownloadHandler> m_handler;
std::atomic_bool m_cancelled;
......@@ -78,10 +78,10 @@ namespace OpenVDS
public:
UploadRequestAWS(const std::string &id, std::function<void(const Request & request, const Error & error)> completedCallback);
void run(Aws::S3::S3Client& client, const std::string& bucket, const std::string& contentDispostionFilename, const std::string& contentType, const std::vector<std::pair<std::string, std::string>>& metadataHeader, std::shared_ptr<std::vector<uint8_t>> data, std::weak_ptr<UploadRequestAWS> uploadRequest);
void waitForFinish() override;
bool isDone() const override;
bool isSuccess(Error &error) const override;
void cancel() override;
void WaitForFinish() override;
bool IsDone() const override;
bool IsSuccess(Error &error) const override;
void Cancel() override;
std::function<void(const Request &request, const Error &error)> m_completedCallback;
std::shared_ptr<IOStream> m_stream;
......@@ -98,8 +98,8 @@ namespace OpenVDS
IOManagerAWS(const AWSOpenOptions &openOptions, Error &error);
~IOManagerAWS() override;
std::shared_ptr<Request> download(const std::string objectName, std::shared_ptr<TransferDownloadHandler> handler, const IORange& range = IORange()) override;
std::shared_ptr<Request> upload(const std::string objectName, const std::string& contentDispostionFilename, const std::string& contentType, const std::vector<std::pair<std::string, std::string>>& metadataHeader, std::shared_ptr<std::vector<uint8_t>> data, std::function<void(const Request & request, const Error & error)> completedCallback = nullptr) override;
std::shared_ptr<Request> Download(const std::string objectName, std::shared_ptr<TransferDownloadHandler> handler, const IORange& range = IORange()) override;
std::shared_ptr<Request> Upload(const std::string objectName, const std::string& contentDispostionFilename, const std::string& contentType, const std::vector<std::pair<std::string, std::string>>& metadataHeader, std::shared_ptr<std::vector<uint8_t>> data, std::function<void(const Request & request, const Error & error)> completedCallback = nullptr) override;
private:
std::string m_region;
std::string m_bucket;
......
......@@ -23,7 +23,7 @@
#include <fmt/format.h>
void downloadObject()
void DownloadObject()
{
azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(_XPLATSTR("DefaultEndpointsProtocol=https;AccountName=myaccountname;AccountKey=myaccountkey"));
azure::storage::cloud_blob_client blob_client = storage_account.create_cloud_blob_client();
......
......@@ -18,6 +18,6 @@
#ifndef IOMANAGERAZURE_H
#define IOMANAGERAZURE_H
void downloadObject();
void DownloadObject();
#endif //IOMANAGERAZURE_H
......@@ -35,32 +35,32 @@
namespace OpenVDS
{
static std::string error_to_string(int error)
static std::string ErrorToString(int error)
{
return std::string(strerror(error));
}
static void set_io_error(int error, IOError &io_error)
static void SetIoError(int error, IOError &io_error)
{
io_error.code = error;
io_error.string = error_to_string(error);
io_error.string = ErrorToString(error);
}
static void set_io_error(int error, std::string &error_string_prefix, IOError &io_error)
static void SetIoError(int error, std::string &error_string_prefix, IOError &io_error)
{
io_error.code = error;
io_error.string = error_string_prefix + error_to_string(error);
io_error.string = error_string_prefix + ErrorToString(error);
}
template<size_t N>
static void set_io_error(int error, const char (&error_string_prefix)[N], IOError &io_error)
static void SetIoError(int error, const char (&error_string_prefix)[N], IOError &io_error)
{
io_error.code = error;
io_error.string = std::string(error_string_prefix, N) + error_to_string(error);
io_error.string = std::string(error_string_prefix, N) + ErrorToString(error);
}
template<size_t N>
static void set_io_error(const char (&error_string_prefix)[N], IOError &io_error)
static void SetIoError(const char (&error_string_prefix)[N], IOError &io_error)
{
io_error.code = -1;
io_error.string = std::string(error_string_prefix, N);
......@@ -142,7 +142,7 @@ public:
if (m_pxBaseAddress == MAP_FAILED)
{
set_io_error(errno, "FileView failed ", error);
SetIoError(errno, "FileView failed ", error);
return;
}
......@@ -152,7 +152,7 @@ public:
if (iRetval != 0)
{
set_io_error(errno, "FileView failed ", error);
SetIoError(errno, "FileView failed ", error);
}
}
}
......@@ -168,7 +168,7 @@ public:
}
}
bool prefetch(const void *pData, int64_t nSize, IOError &error) const override
bool Prefetch(const void *pData, int64_t nSize, IOError &error) const override
{
int64_t nDelta = (int64_t)((uintptr_t)pData % s_nPageSize);
......@@ -179,22 +179,22 @@ public:
if (iRetval != 0)
{
set_io_error(errno, "FileView::prefetch ", error);
SetIoError(errno, "FileView::prefetch ", error);
return false;
}
return true;
}
};
bool File::exists(const std::string& filename)
bool File::Exists(const std::string& filename)
{
struct stat buf;
return (lstat(filename.c_str(), &buf) == 0) && S_ISREG(buf.st_mode);
}
bool File::open(const std::string& filename, bool isCreate, bool isDestroyExisting, bool isWriteAccess, IOError &error)
bool File::Open(const std::string& filename, bool isCreate, bool isDestroyExisting, bool isWriteAccess, IOError &error)
{
assert(!isOpen());
assert(!IsOpen());
assert(!isDestroyExisting || isCreate);
assert(!isCreate || isWriteAccess || !"it is meaningless to demand creation with RO access");
assert(!_pxPlatformHandle || ("RawFileAccess_c::Open: file already open"));
......@@ -211,7 +211,7 @@ bool File::open(const std::string& filename, bool isCreate, bool isDestroyExisti
if (fd < 0)
{
_pxPlatformHandle = 0;
set_io_error(errno, "File::open ", error);
SetIoError(errno, "File::open ", error);
return false;
}
......@@ -220,9 +220,9 @@ bool File::open(const std::string& filename, bool isCreate, bool isDestroyExisti
return true;
}
void File::close()
void File::Close()
{
assert(isOpen());
assert(IsOpen());
int fd = (int)(intptr_t)_pxPlatformHandle;
bool isOK = ::close(fd) == 0;
......@@ -232,20 +232,20 @@ void File::close()
//return isOK;
}
int64_t File::size(IOError& error) const
int64_t File::Size(IOError& error) const
{
int fd = (int)(intptr_t)_pxPlatformHandle;
int64_t nLength = lseek(fd, 0, SEEK_END);
if (nLength < 0)
{
set_io_error(errno, "File::size ", error);
SetIoError(errno, "File::size ", error);
return -1;
}
return nLength;
}
bool File::read(void* pxData, int64_t nOffset, int32_t nLength, IOError& error) const
bool File::Read(void* pxData, int64_t nOffset, int32_t nLength, IOError& error) const
{
assert(nOffset >= 0);
int fd = (int)(intptr_t)_pxPlatformHandle;
......@@ -258,13 +258,13 @@ bool File::read(void* pxData, int64_t nOffset, int32_t nLength, IOError& error)
if (nread < 0)
{
set_io_error(errno, "File::read ", error);
SetIoError(errno, "File::read ", error);
return false;
}
if (nread == 0)
{
set_io_error(errno, "File::read (zero-length read) ", error);
SetIoError(errno, "File::read (zero-length read) ", error);
return false;
}
......@@ -275,13 +275,13 @@ bool File::read(void* pxData, int64_t nOffset, int32_t nLength, IOError& error)
return true;
}
bool File::write(const void* pxData, int64_t nOffset, int32_t nLength, IOError & error)
bool File::Write(const void* pxData, int64_t nOffset, int32_t nLength, IOError & error)
{
assert(nOffset >= 0);
if (!_isWriteable)
{
set_io_error("File::write: file not writeable", error);
SetIoError("File::write: file not writeable", error);
return false;
}
......@@ -295,12 +295,12 @@ bool File::write(const void* pxData, int64_t nOffset, int32_t nLength, IOError &
if (nwritten < 0)
{
set_io_error(errno, "File::write ", error);
SetIoError(errno, "File::write ", error);
return false;
}
if (nwritten == 0)
{
set_io_error(errno, "File::write (zero-length write)", error);
SetIoError(errno, "File::write (zero-length write)", error);
return false;
}
......@@ -311,7 +311,7 @@ bool File::write(const void* pxData, int64_t nOffset, int32_t nLength, IOError &
return true;
}
bool File::flush()
bool File::Flush()
{
#ifdef LINUX
int fd = (int)(intptr_t)_pxPlatformHandle;
......@@ -322,17 +322,17 @@ bool File::flush()
#endif