SNode.C
Loading...
Searching...
No Matches
ConfigAddress.h
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef NET_UN_CONFIG_CONFIGADDRESS_H
21#define NET_UN_CONFIG_CONFIGADDRESS_H
22
23#include "net/config/ConfigAddressLocal.h"
24#include "net/config/ConfigAddressRemote.h"
25#include "net/config/ConfigAddressReverse.h"
26#include "net/un/SocketAddress.h"
27
28namespace net::config {
29 class ConfigInstance;
30}
31
32#ifndef DOXYGEN_SHOULD_SKIP_THIS
33
34#include <string>
35
36namespace CLI {
37 class Option;
38} // namespace CLI
39
40#endif /* DOXYGEN_SHOULD_SKIP_THIS */
41
42namespace net::un::config {
43
44 template <template <typename SocketAddressT> typename ConfigAddressTypeT>
45 class ConfigAddressReverse : public ConfigAddressTypeT<net::un::SocketAddress> {
46 private:
47 using Super = ConfigAddressTypeT<SocketAddress>;
48
49 protected:
50 using Super::Super;
51 };
52
53 template <template <typename SocketAddressT> typename ConfigAddressTypeT>
54 class ConfigAddress : public ConfigAddressTypeT<net::un::SocketAddress> {
55 private:
56 using Super = ConfigAddressTypeT<net::un::SocketAddress>;
57
58 protected:
59 explicit ConfigAddress(net::config::ConfigInstance* instance,
60 const std::string& addressOptionName,
61 const std::string& addressOptionDescription);
62
63 private:
64 SocketAddress* init() final;
65
66 public:
67 ConfigAddress& setSocketAddress(const SocketAddress& socketAddress);
68
69 ConfigAddress& setSunPath(const std::string& sunPath);
70 std::string getSunPath() const;
71
72 protected:
73 ConfigAddress& sunPathRequired(bool required = true);
74
75 private:
76 CLI::Option* sunPathOpt = nullptr;
77 };
78
79} // namespace net::un::config
80
81extern template class net::config::ConfigAddress<net::un::SocketAddress>;
82extern template class net::config::ConfigAddressLocal<net::un::SocketAddress>;
83extern template class net::config::ConfigAddressRemote<net::un::SocketAddress>;
84extern template class net::config::ConfigAddressReverse<net::un::SocketAddress>;
85extern template class net::config::ConfigAddressBase<net::un::SocketAddress>;
86extern template class net::un::config::ConfigAddress<net::config::ConfigAddressLocal>;
87extern template class net::un::config::ConfigAddress<net::config::ConfigAddressRemote>;
88extern template class net::un::config::ConfigAddressReverse<net::config::ConfigAddressReverse>;
89
90#endif // NET_L2_CONFIG_CONFIGADDRESS_H
ConfigAddress & setSunPath(const std::string &sunPath)
SocketAddress * init() final
ConfigAddress & sunPathRequired(bool required=true)
ConfigAddress(net::config::ConfigInstance *instance, const std::string &addressOptionName, const std::string &addressOptionDescription)
ConfigAddress & setSocketAddress(const SocketAddress &socketAddress)