mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 10:10:05 +00:00 
			
		
		
		
	Adding generic level 2 data provider, and documenting virtual functions
This commit is contained in:
		
							parent
							
								
									df3d65e8aa
								
							
						
					
					
						commit
						63474cddcc
					
				
					 4 changed files with 112 additions and 8 deletions
				
			
		|  | @ -1,10 +1,6 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <scwx/wsr88d/ar2v_file.hpp> | #include <scwx/provider/level2_data_provider.hpp> | ||||||
| 
 |  | ||||||
| #include <chrono> |  | ||||||
| #include <memory> |  | ||||||
| #include <string> |  | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx | ||||||
| { | { | ||||||
|  | @ -13,7 +9,10 @@ namespace provider | ||||||
| 
 | 
 | ||||||
| class AwsLevel2DataProviderImpl; | class AwsLevel2DataProviderImpl; | ||||||
| 
 | 
 | ||||||
| class AwsLevel2DataProvider | /**
 | ||||||
|  |  * @brief AWS Level 2 Data Provider | ||||||
|  |  */ | ||||||
|  | class AwsLevel2DataProvider : public Level2DataProvider | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit AwsLevel2DataProvider(const std::string& radarSite); |    explicit AwsLevel2DataProvider(const std::string& radarSite); | ||||||
|  |  | ||||||
							
								
								
									
										74
									
								
								wxdata/include/scwx/provider/level2_data_provider.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								wxdata/include/scwx/provider/level2_data_provider.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,74 @@ | ||||||
|  | #pragma once | ||||||
|  | 
 | ||||||
|  | #include <scwx/wsr88d/ar2v_file.hpp> | ||||||
|  | 
 | ||||||
|  | #include <chrono> | ||||||
|  | #include <memory> | ||||||
|  | #include <string> | ||||||
|  | 
 | ||||||
|  | namespace scwx | ||||||
|  | { | ||||||
|  | namespace provider | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | class Level2DataProviderImpl; | ||||||
|  | 
 | ||||||
|  | class Level2DataProvider | ||||||
|  | { | ||||||
|  | public: | ||||||
|  |    explicit Level2DataProvider(); | ||||||
|  |    ~Level2DataProvider(); | ||||||
|  | 
 | ||||||
|  |    Level2DataProvider(const Level2DataProvider&) = delete; | ||||||
|  |    Level2DataProvider& operator=(const Level2DataProvider&) = delete; | ||||||
|  | 
 | ||||||
|  |    Level2DataProvider(Level2DataProvider&&) noexcept; | ||||||
|  |    Level2DataProvider& operator=(Level2DataProvider&&) noexcept; | ||||||
|  | 
 | ||||||
|  |    virtual size_t cache_size() 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 Level 2 data key | ||||||
|  |     */ | ||||||
|  |    virtual std::string FindKey(std::chrono::system_clock::time_point time) = 0; | ||||||
|  | 
 | ||||||
|  |    /**
 | ||||||
|  |     * Lists level 2 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 level 2 object by the given key. | ||||||
|  |     * | ||||||
|  |     * @param key Level 2 data key | ||||||
|  |     * | ||||||
|  |     * @return Level 2 data | ||||||
|  |     */ | ||||||
|  |    virtual std::shared_ptr<wsr88d::Ar2vFile> | ||||||
|  |    LoadObjectByKey(const std::string& key) = 0; | ||||||
|  | 
 | ||||||
|  |    /**
 | ||||||
|  |     * Lists level 2 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; | ||||||
|  | 
 | ||||||
|  | private: | ||||||
|  |    std::unique_ptr<Level2DataProviderImpl> p; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | } // namespace provider
 | ||||||
|  | } // namespace scwx
 | ||||||
							
								
								
									
										29
									
								
								wxdata/source/scwx/provider/level2_data_provider.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								wxdata/source/scwx/provider/level2_data_provider.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | ||||||
|  | #include <scwx/provider/level2_data_provider.hpp> | ||||||
|  | 
 | ||||||
|  | namespace scwx | ||||||
|  | { | ||||||
|  | namespace provider | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | static const std::string logPrefix_ = "scwx::provider::level2_data_provider"; | ||||||
|  | 
 | ||||||
|  | class Level2DataProviderImpl | ||||||
|  | { | ||||||
|  | public: | ||||||
|  |    explicit Level2DataProviderImpl() {} | ||||||
|  | 
 | ||||||
|  |    ~Level2DataProviderImpl() {} | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | Level2DataProvider::Level2DataProvider() : | ||||||
|  |     p(std::make_unique<Level2DataProviderImpl>()) | ||||||
|  | { | ||||||
|  | } | ||||||
|  | Level2DataProvider::~Level2DataProvider() = default; | ||||||
|  | 
 | ||||||
|  | Level2DataProvider::Level2DataProvider(Level2DataProvider&&) noexcept = default; | ||||||
|  | Level2DataProvider& | ||||||
|  | Level2DataProvider::operator=(Level2DataProvider&&) noexcept = default; | ||||||
|  | 
 | ||||||
|  | } // namespace provider
 | ||||||
|  | } // namespace scwx
 | ||||||
|  | @ -34,8 +34,10 @@ set(SRC_COMMON source/scwx/common/color_table.cpp | ||||||
|                source/scwx/common/products.cpp |                source/scwx/common/products.cpp | ||||||
|                source/scwx/common/sites.cpp |                source/scwx/common/sites.cpp | ||||||
|                source/scwx/common/vcp.cpp) |                source/scwx/common/vcp.cpp) | ||||||
| set(HDR_PROVIDER include/scwx/provider/aws_level2_data_provider.hpp) | set(HDR_PROVIDER include/scwx/provider/aws_level2_data_provider.hpp | ||||||
| set(SRC_PROVIDER source/scwx/provider/aws_level2_data_provider.cpp) |                  include/scwx/provider/level2_data_provider.hpp) | ||||||
|  | set(SRC_PROVIDER source/scwx/provider/aws_level2_data_provider.cpp | ||||||
|  |                  source/scwx/provider/level2_data_provider.cpp) | ||||||
| set(HDR_UTIL include/scwx/util/float.hpp | set(HDR_UTIL include/scwx/util/float.hpp | ||||||
|              include/scwx/util/iterator.hpp |              include/scwx/util/iterator.hpp | ||||||
|              include/scwx/util/logger.hpp |              include/scwx/util/logger.hpp | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat