Nebula
Toggle main menu visibility
Loading...
Searching...
No Matches
httpclientregistry.h
Go to the documentation of this file.
1
#pragma once
2
//------------------------------------------------------------------------------
14
15
#include "
core/refcounted.h
"
16
#include "
core/singleton.h
"
17
#include "
http/httpclient.h
"
18
#include "
io/uri.h
"
19
#include "
util/dictionary.h
"
20
#include "
util/stringatom.h
"
21
22
//------------------------------------------------------------------------------
23
namespace
Http
24
{
25
class
HttpClientRegistry
:
public
Core::RefCounted
26
{
27
__DeclareClass
(
HttpClientRegistry
);
28
__DeclareSingleton
(
HttpClientRegistry
);
29
public
:
31
HttpClientRegistry
();
33
virtual
~HttpClientRegistry
();
34
36
void
Setup
();
38
void
Discard
();
40
bool
IsValid
()
const
;
41
43
Ptr<HttpClient>
ObtainConnection
(
const
IO::URI
& uri);
45
void
ReleaseConnection
(
const
IO::URI
& uri);
47
bool
IsConnected
(
const
IO::URI
& uri)
const
;
49
void
DisconnectIdle
();
50
51
private
:
52
struct
Connection
53
{
54
Ptr<HttpClient>
httpClient
;
55
SizeT
useCount
;
56
};
57
58
Util::Dictionary<Util::StringAtom, Connection>
connections
;
59
bool
isValid
;
60
};
61
62
//------------------------------------------------------------------------------
65
inline
bool
66
HttpClientRegistry::IsValid
()
const
67
{
68
return
this->
isValid
;
69
}
70
71
}
// namespace Http
72
//------------------------------------------------------------------------------
Core::RefCounted
The common base class of Nebula.
Definition
refcounted.h:38
Http::HttpClientRegistry::HttpClientRegistry
HttpClientRegistry()
constructor
Definition
httpclientregistry.cc:20
Http::HttpClientRegistry::ReleaseConnection
void ReleaseConnection(const IO::URI &uri)
give up connection to a HTTP server, this will NEVER disconnect!
Definition
httpclientregistry.cc:127
Http::HttpClientRegistry::ObtainConnection
Ptr< HttpClient > ObtainConnection(const IO::URI &uri)
open a connection to a HTTP server, reuse connection if already connected
Definition
httpclientregistry.cc:94
Http::HttpClientRegistry::IsValid
bool IsValid() const
return true if the object has been setup
Definition
httpclientregistry.h:66
Http::HttpClientRegistry::isValid
bool isValid
Definition
httpclientregistry.h:59
Http::HttpClientRegistry::__DeclareSingleton
__DeclareSingleton(HttpClientRegistry)
Http::HttpClientRegistry::connections
Util::Dictionary< Util::StringAtom, Connection > connections
Definition
httpclientregistry.h:58
Http::HttpClientRegistry::IsConnected
bool IsConnected(const IO::URI &uri) const
check if a connection to an HTTP server exists
Definition
httpclientregistry.cc:143
Http::HttpClientRegistry::DisconnectIdle
void DisconnectIdle()
disconnect all connections with a zero use count
Definition
httpclientregistry.cc:72
Http::HttpClientRegistry::Setup
void Setup()
setup the client registry
Definition
httpclientregistry.cc:42
Http::HttpClientRegistry::__DeclareClass
__DeclareClass(HttpClientRegistry)
Http::HttpClientRegistry::Discard
void Discard()
discard the client registry, closes all open connections
Definition
httpclientregistry.cc:52
IO::URI
An URI object can split a Uniform Resource Identifier string into its components or build a string fr...
Definition
uri.h:67
Ptr
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition
ptr.h:38
Util::Dictionary
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition
dictionary.h:35
dictionary.h
httpclient.h
Http
This file was generated with Nebula Trifid's idlc compiler tool.
Definition
defaulthttprequesthandler.cc:15
refcounted.h
singleton.h
stringatom.h
Http::HttpClientRegistry::Connection
Definition
httpclientregistry.h:53
Http::HttpClientRegistry::Connection::httpClient
Ptr< HttpClient > httpClient
Definition
httpclientregistry.h:54
Http::HttpClientRegistry::Connection::useCount
SizeT useCount
Definition
httpclientregistry.h:55
SizeT
int SizeT
Definition
types.h:42
uri.h
code
foundation
http
httpclientregistry.h
Generated on
for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.