mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:30:05 +00:00
Refactoring AWS level 2 data provider, pushing up common functions
This commit is contained in:
parent
394aba2d83
commit
c5c54fbfa2
13 changed files with 512 additions and 439 deletions
107
wxdata/include/scwx/provider/nexrad_data_provider.hpp
Normal file
107
wxdata/include/scwx/provider/nexrad_data_provider.hpp
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/wsr88d/nexrad_file.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace provider
|
||||
{
|
||||
|
||||
class NexradDataProvider
|
||||
{
|
||||
public:
|
||||
explicit NexradDataProvider();
|
||||
~NexradDataProvider();
|
||||
|
||||
NexradDataProvider(const NexradDataProvider&) = delete;
|
||||
NexradDataProvider& operator=(const NexradDataProvider&) = delete;
|
||||
|
||||
NexradDataProvider(NexradDataProvider&&) noexcept;
|
||||
NexradDataProvider& operator=(NexradDataProvider&&) noexcept;
|
||||
|
||||
virtual size_t cache_size() const = 0;
|
||||
|
||||
/**
|
||||
* Gets the last modified time. This is equal to the most recent object's
|
||||
* modification time. If there are no objects, the epoch is returned.
|
||||
*
|
||||
* @return Last modified time
|
||||
*/
|
||||
virtual std::chrono::system_clock::time_point last_modified() const = 0;
|
||||
|
||||
/**
|
||||
* Gets the current update period. This is equal to the difference between
|
||||
* the last two objects' modification times. If there are less than two
|
||||
* objects, an update period of 0 is returned.
|
||||
*
|
||||
* @return Update period
|
||||
*/
|
||||
virtual std::chrono::seconds update_period() const = 0;
|
||||
|
||||
/**
|
||||
* Finds the most recent key in the cache, no later than the time provided.
|
||||
*
|
||||
* @param time Upper-bound time for the key search
|
||||
*
|
||||
* @return NEXRAD data key
|
||||
*/
|
||||
virtual std::string FindKey(std::chrono::system_clock::time_point time) = 0;
|
||||
|
||||
/**
|
||||
* Finds the most recent key in the cache.
|
||||
*
|
||||
* @return NEXRAD data key
|
||||
*/
|
||||
virtual std::string FindLatestKey() = 0;
|
||||
|
||||
/**
|
||||
* Lists NEXRAD objects for the date supplied, and adds them to the cache.
|
||||
*
|
||||
* @param date Date for which to list objects
|
||||
*
|
||||
* @return - New objects found for the given date
|
||||
* - Total objects found for the given date
|
||||
*/
|
||||
virtual std::pair<size_t, size_t>
|
||||
ListObjects(std::chrono::system_clock::time_point date) = 0;
|
||||
|
||||
/**
|
||||
* Loads a NEXRAD file object by the given key.
|
||||
*
|
||||
* @param key NEXRAD data key
|
||||
*
|
||||
* @return NEXRAD data
|
||||
*/
|
||||
virtual std::shared_ptr<wsr88d::NexradFile>
|
||||
LoadObjectByKey(const std::string& key) = 0;
|
||||
|
||||
/**
|
||||
* Lists NEXRAD objects for the current date, and adds them to the cache. If
|
||||
* no objects have been added to the cache for the current date, the previous
|
||||
* date is also queried for data.
|
||||
*
|
||||
* @return New objects found
|
||||
*/
|
||||
virtual size_t Refresh() = 0;
|
||||
|
||||
/**
|
||||
* Convert the object key to a time point.
|
||||
*
|
||||
* @key NEXRAD data key
|
||||
*
|
||||
* @return NEXRAD data time point
|
||||
*/
|
||||
virtual std::chrono::system_clock::time_point
|
||||
GetTimePointByKey(const std::string& key) const = 0;
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> p;
|
||||
};
|
||||
|
||||
} // namespace provider
|
||||
} // namespace scwx
|
||||
Loading…
Add table
Add a link
Reference in a new issue