KiCad PCB EDA Suite
Loading...
Searching...
No Matches
HTTP_LIB_CONNECTION Class Reference

#include <http_lib_connection.h>

Public Member Functions

 HTTP_LIB_CONNECTION (const HTTP_LIB_SOURCE &aSource, bool aTestConnectionNow)
 
virtual ~HTTP_LIB_CONNECTION ()=default
 
bool IsValidEndpoint () const
 
bool SelectOne (const std::string &aPartID, HTTP_LIB_PART &aFetchedPart)
 Retrieve a single part with full details from the HTTP library.
 
bool SelectAll (const HTTP_LIB_CATEGORY &aCategory, std::vector< HTTP_LIB_PART > &aParts)
 Retrieve all parts from a specific category from the HTTP library.
 
std::string GetLastError () const
 
std::vector< HTTP_LIB_CATEGORYgetCategories () const
 
std::string getCategoryDescription (const std::string &aCategoryName) const
 
auto & GetCachedParts ()
 

Static Public Attributes

static const long DEFAULT_TIMEOUT = 10
 

Private Member Functions

std::unique_ptr< KICAD_CURL_EASYcreateCurlEasyObject ()
 
bool validateHttpLibraryEndpoints ()
 
bool syncCategories ()
 
bool checkServerResponse (std::unique_ptr< KICAD_CURL_EASY > &aCurl)
 
wxString httpErrorCodeDescription (uint16_t aHttpCode)
 HTTP response status codes indicate whether a specific HTTP request has been successfully completed.
 

Private Attributes

HTTP_LIB_SOURCE m_source
 
bool m_endpointValid = false
 
std::string m_lastError
 
std::vector< HTTP_LIB_CATEGORYm_categories
 
std::map< std::string, std::string > m_categoryDescriptions
 
std::map< std::string, std::string > m_parts
 
std::map< std::string, HTTP_LIB_PARTm_cachedParts
 
std::map< std::string, std::tuple< std::string, std::string > > m_cache
 

Detailed Description

Definition at line 45 of file http_lib_connection.h.

Constructor & Destructor Documentation

◆ HTTP_LIB_CONNECTION()

HTTP_LIB_CONNECTION::HTTP_LIB_CONNECTION ( const HTTP_LIB_SOURCE & aSource,
bool aTestConnectionNow )

Definition at line 39 of file http_lib_connection.cpp.

References m_source, and validateHttpLibraryEndpoints().

◆ ~HTTP_LIB_CONNECTION()

virtual HTTP_LIB_CONNECTION::~HTTP_LIB_CONNECTION ( )
virtualdefault

Member Function Documentation

◆ checkServerResponse()

bool HTTP_LIB_CONNECTION::checkServerResponse ( std::unique_ptr< KICAD_CURL_EASY > & aCurl)
private

◆ createCurlEasyObject()

std::unique_ptr< KICAD_CURL_EASY > HTTP_LIB_CONNECTION::createCurlEasyObject ( )
inlineprivate

Definition at line 91 of file http_lib_connection.h.

References m_source.

Referenced by SelectAll(), SelectOne(), syncCategories(), and validateHttpLibraryEndpoints().

◆ GetCachedParts()

auto & HTTP_LIB_CONNECTION::GetCachedParts ( )
inline

Definition at line 85 of file http_lib_connection.h.

References m_cache.

◆ getCategories()

std::vector< HTTP_LIB_CATEGORY > HTTP_LIB_CONNECTION::getCategories ( ) const
inline

Definition at line 75 of file http_lib_connection.h.

References m_categories.

◆ getCategoryDescription()

std::string HTTP_LIB_CONNECTION::getCategoryDescription ( const std::string & aCategoryName) const
inline

Definition at line 77 of file http_lib_connection.h.

References m_categoryDescriptions.

◆ GetLastError()

std::string HTTP_LIB_CONNECTION::GetLastError ( ) const
inline

Definition at line 73 of file http_lib_connection.h.

References m_lastError.

Referenced by BOOST_AUTO_TEST_CASE().

◆ httpErrorCodeDescription()

wxString HTTP_LIB_CONNECTION::httpErrorCodeDescription ( uint16_t aHttpCode)
private

HTTP response status codes indicate whether a specific HTTP request has been successfully completed.

Responses are grouped in five classes:

Definition at line 422 of file http_lib_connection.cpp.

Referenced by checkServerResponse().

◆ IsValidEndpoint()

bool HTTP_LIB_CONNECTION::IsValidEndpoint ( ) const
inline

Definition at line 53 of file http_lib_connection.h.

References m_endpointValid.

Referenced by BOOST_AUTO_TEST_CASE(), SelectAll(), SelectOne(), and syncCategories().

◆ SelectAll()

bool HTTP_LIB_CONNECTION::SelectAll ( const HTTP_LIB_CATEGORY & aCategory,
std::vector< HTTP_LIB_PART > & aParts )

Retrieve all parts from a specific category from the HTTP library.

Parameters
aCategoryis the category to fetch parts from
aPartswill be filled with all parts in that category
Returns
true if the query succeeded and at least one part was found, false otherwise

Definition at line 350 of file http_lib_connection.cpp.

References _, createCurlEasyObject(), HTTP_LIB_PART::detailsLoaded, HTTP_LIB_CATEGORY::id, HTTP_LIB_PART::id, IsValidEndpoint(), HTTP_LIB_PART::lastCached, m_cache, m_cachedParts, m_lastError, m_source, HTTP_LIB_PART::name, res, setPartExtendedData(), setPartIdNameAndMetadata(), and traceHTTPLib.

◆ SelectOne()

bool HTTP_LIB_CONNECTION::SelectOne ( const std::string & aPartID,
HTTP_LIB_PART & aFetchedPart )

Retrieve a single part with full details from the HTTP library.

Parameters
aPartIDis the unique ID of the part
aFetchedPartwill contain the part if one was found
Returns
true if aResult was filled; false otherwise

Definition at line 278 of file http_lib_connection.cpp.

References _, HTTP_LIB_PART::associated_footprints, checkServerResponse(), createCurlEasyObject(), HTTP_LIB_PART::detailsLoaded, HTTP_LIB_PART::id, IsValidEndpoint(), HTTP_LIB_PART::lastCached, m_cachedParts, m_lastError, m_source, HTTP_LIB_PART::named_pin_maps, ParseAssociatedFootprints(), ParseLegacyPinAssignments(), ParsePinMapSet(), HTTP_LIB_PART::pin_map, res, setPartExtendedData(), setPartIdNameAndMetadata(), and traceHTTPLib.

◆ syncCategories()

◆ validateHttpLibraryEndpoints()

bool HTTP_LIB_CONNECTION::validateHttpLibraryEndpoints ( )
private

Member Data Documentation

◆ DEFAULT_TIMEOUT

const long HTTP_LIB_CONNECTION::DEFAULT_TIMEOUT = 10
static

Definition at line 48 of file http_lib_connection.h.

◆ m_cache

std::map<std::string, std::tuple<std::string, std::string> > HTTP_LIB_CONNECTION::m_cache
private

Definition at line 137 of file http_lib_connection.h.

Referenced by GetCachedParts(), and SelectAll().

◆ m_cachedParts

std::map<std::string, HTTP_LIB_PART> HTTP_LIB_CONNECTION::m_cachedParts
private

Definition at line 134 of file http_lib_connection.h.

Referenced by SelectAll(), and SelectOne().

◆ m_categories

std::vector<HTTP_LIB_CATEGORY> HTTP_LIB_CONNECTION::m_categories
private

Definition at line 129 of file http_lib_connection.h.

Referenced by getCategories(), and syncCategories().

◆ m_categoryDescriptions

std::map<std::string, std::string> HTTP_LIB_CONNECTION::m_categoryDescriptions
private

Definition at line 130 of file http_lib_connection.h.

Referenced by getCategoryDescription(), and syncCategories().

◆ m_endpointValid

bool HTTP_LIB_CONNECTION::m_endpointValid = false
private

Definition at line 126 of file http_lib_connection.h.

Referenced by IsValidEndpoint(), and validateHttpLibraryEndpoints().

◆ m_lastError

std::string HTTP_LIB_CONNECTION::m_lastError
private

◆ m_parts

std::map<std::string, std::string> HTTP_LIB_CONNECTION::m_parts
private

Definition at line 131 of file http_lib_connection.h.

◆ m_source

HTTP_LIB_SOURCE HTTP_LIB_CONNECTION::m_source
private

The documentation for this class was generated from the following files: