Skip to content

Commit c9b0fbf

Browse files
move includes from aether.h and use forward declarations
1 parent 5e21ac5 commit c9b0fbf

9 files changed

Lines changed: 75 additions & 46 deletions

File tree

aether/ae_actions/telemetry.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# include "aether/aether.h"
2222
# include "aether/format/format.h"
2323
# include "aether/tele/traps/statistics_trap.h"
24+
# include "aether/tele/traps/tele_statistics.h"
2425

2526
# include "aether/mstream.h"
2627
# include "aether/mstream_buffers.h"
@@ -111,7 +112,9 @@ std::optional<Telemetric> Telemetry::CollectTelemetry(
111112
return std::nullopt;
112113
}
113114
auto& statistics_storage =
114-
aether_ptr->tele_statistics->trap()->statistics_store;
115+
tele::TeleStatistics::ptr{aether_ptr->tele_statistics}
116+
->trap()
117+
->statistics_store;
115118
auto& env_storage = statistics_storage.env_store();
116119
Telemetric res{};
117120
res.cpp.utm_id = env_storage.utm_id;

aether/aether.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,38 @@
1818

1919
#include <utility>
2020

21-
#include "aether/global_ids.h"
2221
#include "aether/obj/obj_ptr.h"
22+
#include "aether/ae_actions/time_sync.h"
23+
#include "aether/actions/action_processor.h"
24+
25+
#include "aether/client.h"
26+
#include "aether/server.h"
27+
#include "aether/registration_cloud.h"
2328

2429
#include "aether/work_cloud.h"
30+
#include "aether/registration/registration.h"
2531

2632
#include "aether/aether_tele.h"
2733

2834
namespace ae {
2935

30-
Aether::Aether(ObjProp prop) : Obj{prop} { AE_TELE_DEBUG(AetherCreated); }
36+
Aether::Aether() : action_processor{make_unique<ActionProcessor>()} {}
37+
38+
Aether::Aether(ObjProp prop)
39+
: Obj{prop}, action_processor{make_unique<ActionProcessor>()} {
40+
AE_TELE_DEBUG(AetherCreated);
41+
}
3142

3243
Aether::~Aether() { AE_TELE_DEBUG(AetherDestroyed); }
3344

3445
void Aether::Update(TimePoint current_time) {
3546
update_time = action_processor->Update(current_time);
3647
}
3748

49+
Aether::operator ActionContext() const {
50+
return ActionContext{*action_processor};
51+
}
52+
3853
Client::ptr Aether::CreateClient(ClientConfig const& config,
3954
std::string const& client_id) {
4055
auto client = FindClient(client_id);

aether/aether.h

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,33 @@
2525
#include "aether/obj/obj.h"
2626
#include "aether/actions/action_ptr.h"
2727
#include "aether/types/client_config.h"
28-
#include "aether/ae_actions/time_sync.h"
28+
2929
#include "aether/actions/action_context.h"
30-
#include "aether/actions/action_processor.h"
3130
#include "aether/ae_actions/select_client.h"
32-
#include "aether/tele/traps/tele_statistics.h"
33-
#include "aether/registration/registration.h" // IWYU pragma: keep
3431

35-
#include "aether/client.h"
36-
#include "aether/crypto.h"
37-
#include "aether/server.h"
3832
#include "aether/uap/uap.h"
39-
#include "aether/poller/poller.h"
40-
#include "aether/dns/dns_resolve.h"
41-
#include "aether/adapter_registry.h"
42-
#include "aether/registration_cloud.h"
4333

4434
namespace ae {
35+
class Server;
36+
class Client;
37+
class Crypto;
38+
class IPoller;
39+
class DnsResolver;
40+
class Registration;
41+
class TimeSyncAction;
42+
class AdapterRegistry;
43+
class ActionProcessor;
44+
class RegistrationCloud;
45+
class RegistrationCloud;
46+
47+
namespace tele {
48+
class TeleStatistics;
49+
}
50+
4551
class Aether : public Obj {
4652
AE_OBJECT(Aether, Obj, 0)
4753

48-
Aether() = default;
54+
Aether();
4955

5056
public:
5157
// Internal.
@@ -75,40 +81,39 @@ class Aether : public Obj {
7581
void Update(TimePoint current_time) override;
7682

7783
// User-facing API.
78-
operator ActionContext() const { return ActionContext{*action_processor}; }
84+
operator ActionContext() const;
7985

80-
Client::ptr CreateClient(ClientConfig const& config,
81-
std::string const& client_id);
86+
ObjPtr<Client> CreateClient(ClientConfig const& config,
87+
std::string const& client_id);
8288
ActionPtr<SelectClientAction> SelectClient(Uid parent_uid,
8389
std::string const& client_id);
8490

8591
void StoreServer(Server::ptr s);
8692
Server::ptr GetServer(ServerId server_id);
8793

88-
Client::ptr client_prefab;
89-
RegistrationCloud::ptr registration_cloud;
94+
Obj::ptr client_prefab;
95+
Obj::ptr registration_cloud;
9096

91-
Crypto::ptr crypto;
92-
IPoller::ptr poller;
93-
DnsResolver::ptr dns_resolver;
97+
Obj::ptr crypto;
98+
Obj::ptr poller;
99+
Obj::ptr dns_resolver;
94100

95-
AdapterRegistry::ptr adapter_registry;
101+
Obj::ptr adapter_registry;
96102
Uap::ptr uap;
97103

98-
tele::TeleStatistics::ptr tele_statistics;
104+
Obj::ptr tele_statistics;
99105

100-
std::unique_ptr<ActionProcessor> action_processor =
101-
make_unique<ActionProcessor>();
106+
std::unique_ptr<ActionProcessor> action_processor;
102107

103108
private:
104-
Client::ptr FindClient(std::string const& client_id);
105-
void StoreClient(Client::ptr client);
109+
ObjPtr<Client> FindClient(std::string const& client_id);
110+
void StoreClient(ObjPtr<Client> client);
106111

107112
ActionPtr<SelectClientAction> FindSelectClientAction(
108113
std::string const& client_id);
109114
ActionPtr<SelectClientAction> MakeSelectClient() const;
110115
ActionPtr<SelectClientAction> MakeSelectClient(
111-
Client::ptr const& client) const;
116+
ObjPtr<Client> const& client) const;
112117
#if AE_SUPPORT_REGISTRATION
113118
ActionPtr<SelectClientAction> MakeSelectClient(
114119
ActionPtr<Registration> registration, std::string const& client_id);
@@ -119,10 +124,10 @@ class Aether : public Obj {
119124
private:
120125
#endif
121126

122-
void MakeTimeSyncAction(Client::ptr const& client);
127+
void MakeTimeSyncAction(ObjPtr<Client> const& client);
123128

124-
std::map<std::string, Client::ptr> clients_;
125-
std::map<ServerId, Server::ptr> servers_;
129+
std::map<std::string, Obj::ptr> clients_;
130+
std::map<ServerId, Obj::ptr> servers_;
126131

127132
std::map<std::string, ActionPtr<SelectClientAction>> select_client_actions_;
128133
#if AE_TIME_SYNC_ENABLED

aether/aether_app.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "aether/crypto/key.h"
2525
#include "aether/global_ids.h"
2626
#include "aether/adapters/ethernet.h"
27+
#include "aether/registration_cloud.h"
2728
#include "aether/adapters/wifi_adapter.h"
2829
#include "aether/poller/win_poller.h"
2930
#include "aether/poller/epoll_poller.h"
@@ -82,7 +83,8 @@ static Aether::ptr AetherFactory(AetherAppContext const& context) {
8283

8384
static tele::TeleStatistics::ptr TeleStatisticsFactory(
8485
AetherAppContext const& context) {
85-
auto tele_statistics = context.aether()->tele_statistics;
86+
auto tele_statistics =
87+
tele::TeleStatistics::ptr{context.aether()->tele_statistics};
8688
if (tele_statistics.is_valid()) {
8789
return tele_statistics;
8890
}
@@ -98,7 +100,7 @@ static tele::TeleStatistics::ptr TeleStatisticsFactory(
98100
#if AE_DISTILLATION
99101
static AdapterRegistry::ptr AdapterRegistryFactory(
100102
AetherAppContext const& context) {
101-
auto ap = context.aether()->adapter_registry;
103+
auto ap = AdapterRegistry::ptr{context.aether()->adapter_registry};
102104
if (ap.is_valid()) {
103105
return ap;
104106
}
@@ -126,11 +128,11 @@ static Adapter::ptr DefaultAdapterFactory(AetherAppContext const& context) {
126128

127129
# if AE_SUPPORT_REGISTRATION
128130
static Cloud::ptr RegistrationCloudFactory(AetherAppContext const& context) {
129-
auto reg_c = context.aether()->registration_cloud;
130-
if (reg_c.is_valid()) {
131-
return reg_c;
131+
auto cloud = Cloud::ptr{context.aether()->registration_cloud};
132+
if (cloud.is_valid()) {
133+
return cloud;
132134
}
133-
reg_c = RegistrationCloud::ptr::Create(
135+
auto reg_c = RegistrationCloud::ptr::Create(
134136
CreateWith{context.domain()}
135137
.with_id(GlobalId::kRegistrationCloud)
136138
.with_flags(ObjFlags::kUnloadedByDefault),
@@ -151,7 +153,7 @@ static Cloud::ptr RegistrationCloudFactory(AetherAppContext const& context) {
151153
# endif // AE_SUPPORT_REGISTRATION
152154

153155
static Crypto::ptr CryptoFactory(AetherAppContext const& context) {
154-
auto crypto = context.aether()->crypto;
156+
auto crypto = Crypto::ptr{context.aether()->crypto};
155157
if (crypto.is_valid()) {
156158
return crypto;
157159
}
@@ -172,7 +174,7 @@ static Crypto::ptr CryptoFactory(AetherAppContext const& context) {
172174
}
173175

174176
static IPoller::ptr PollerFactory(AetherAppContext const& context) {
175-
auto poller = context.aether()->poller;
177+
auto poller = IPoller::ptr{context.aether()->poller};
176178
if (poller.is_valid()) {
177179
return poller;
178180
}
@@ -202,7 +204,7 @@ static IPoller::ptr PollerFactory(AetherAppContext const& context) {
202204
}
203205

204206
static DnsResolver::ptr DnsResolverFactory(AetherAppContext const& context) {
205-
auto dns_resolver = context.aether()->dns_resolver;
207+
auto dns_resolver = DnsResolver::ptr{context.aether()->dns_resolver};
206208
if (dns_resolver.is_valid()) {
207209
return dns_resolver;
208210
}
@@ -219,7 +221,7 @@ static DnsResolver::ptr DnsResolverFactory(AetherAppContext const& context) {
219221
.with_id(GlobalId::kDnsResolver)
220222
.with_flags(ObjFlags::kUnloadedByDefault),
221223
context.aether());
222-
#else
224+
# else
223225
return {};
224226
# endif
225227
# else

aether/aether_app.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "aether/poller/poller.h"
4343
#include "aether/dns/dns_resolve.h"
4444
#include "aether/adapter_registry.h"
45+
#include "aether/tele/traps/tele_statistics.h"
4546
#include "aether/obj/component_factory.h"
4647

4748
#include "aether/domain_storage/domain_storage_factory.h"

aether/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
* Also choose one of the supported modem implementations.
112112
*/
113113
#ifndef AE_SUPPORT_MODEMS
114-
# define AE_SUPPORT_MODEMS 1
114+
# define AE_SUPPORT_MODEMS 0
115115
#endif
116116

117117
// Thingy91x modem implementation is enabled.

aether/registration/registration.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# include <utility>
2222

2323
# include "aether/aether.h"
24+
# include "aether/crypto.h"
2425
# include "aether/crypto/sign.h"
2526
# include "aether/api_protocol/api_context.h"
2627
# include "aether/crypto/crypto_definitions.h"
@@ -50,7 +51,7 @@ Registration::Registration(ActionContext action_context, Aether& aether,
5051
state_{State::kInitConnection},
5152
// TODO: add configuration
5253
response_timeout_{std::chrono::seconds(20)},
53-
sign_pk_{aether.crypto->signs_pk_[kDefaultSignatureMethod]} {
54+
sign_pk_{Crypto::ptr{aether.crypto}->signs_pk_[kDefaultSignatureMethod]} {
5455
AE_TELE_INFO(RegisterStarted);
5556

5657
// parent uid must not be empty

aether/transport/system_sockets/sockets/win_udp_socket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "aether/config.h"
2121
#include "aether/transport/system_sockets/sockets/win_socket.h" // IWYU pragma: keep
2222

23-
#if AE_SUPPORT_UDP && defined WIN_SOCKET_ENABLED
23+
#if AE_SUPPORT_UDP && WIN_SOCKET_ENABLED
2424

2525
namespace ae {
2626
class WinUdpSocket final : public WinSocket {

tools/registrator/registrator_action.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include "registrator/registrator_action.h"
1818

19+
#include "aether/registration/registration.h"
20+
1921
namespace ae::reg {
2022
RegistratorAction::RegistratorAction(
2123
ActionContext action_context, RcPtr<AetherApp> const& aether_app,

0 commit comments

Comments
 (0)