From d3f31e47f0351b30e4f96e1107318d50abd1cdf5 Mon Sep 17 00:00:00 2001
From: Philipp Jungkamp <philipp.jungkamp@rwth-aachen.de>
Date: Thu, 14 Jul 2022 14:02:04 +0000
Subject: [PATCH] move member initializers from header to contructor

---
 include/villas/nodes/iec60870.hpp | 31 +++++++++++++++----------------
 lib/nodes/iec60870.cpp            | 25 ++++++++++++++++++++++++-
 2 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/include/villas/nodes/iec60870.hpp b/include/villas/nodes/iec60870.hpp
index c0ffcabcf..a454b73d6 100644
--- a/include/villas/nodes/iec60870.hpp
+++ b/include/villas/nodes/iec60870.hpp
@@ -136,22 +136,22 @@ class SlaveNode : public Node {
 protected:
 	struct Server {
 		// slave state
-		enum { NONE, STOPPED, READY } state = NONE;
+		enum { NONE, STOPPED, READY } state;
 
 		// config (use explicit defaults)
-		std::string local_address = "0.0.0.0";
-		int local_port = 2404;
-		int common_address = 1;
-		int low_priority_queue = 100;
-		int high_priority_queue = 100;
+		std::string local_address;
+		int local_port;
+		int common_address;
+		int low_priority_queue;
+		int high_priority_queue;
 
 		// config (use lib60870 defaults if std::nullopt)
-		std::optional<int> apci_t0 = std::nullopt;
-		std::optional<int> apci_t1 = std::nullopt;
-		std::optional<int> apci_t2 = std::nullopt;
-		std::optional<int> apci_t3 = std::nullopt;
-		std::optional<int> apci_k = std::nullopt;
-		std::optional<int> apci_w = std::nullopt;
+		std::optional<int> apci_t0;
+		std::optional<int> apci_t1;
+		std::optional<int> apci_t2;
+		std::optional<int> apci_t3;
+		std::optional<int> apci_k;
+		std::optional<int> apci_w;
 
 		// lib60870
 		CS104_Slave slave;
@@ -159,13 +159,12 @@ protected:
 	} server;
 
 	struct Output {
-		// config
 		bool enabled = false;
-		std::vector<ASDUData> mapping = {};
-		std::vector<ASDUData::Type> asdu_types = {};
+		std::vector<ASDUData> mapping;
+		std::vector<ASDUData::Type> asdu_types;
 
 		mutable std::mutex last_values_mutex;
-		std::vector<SignalData> last_values = {};
+		std::vector<SignalData> last_values;
 	} output;
 
 	void createSlave() noexcept;
diff --git a/lib/nodes/iec60870.cpp b/lib/nodes/iec60870.cpp
index 3faf13c01..88d82ba15 100644
--- a/lib/nodes/iec60870.cpp
+++ b/lib/nodes/iec60870.cpp
@@ -311,7 +311,8 @@ bool ASDUData::addSampleToASDU(CS101_ASDU &asdu, ASDUData::Sample sample) const
 }
 
 ASDUData::ASDUData(ASDUData::Descriptor const *descriptor, int ioa, int ioa_sequence_start) : ioa(ioa), ioa_sequence_start(ioa_sequence_start), descriptor(descriptor)
-{}
+{
+}
 
 void SlaveNode::createSlave() noexcept
 {
@@ -576,6 +577,28 @@ int SlaveNode::_write(Sample *samples[], unsigned sample_count)
 SlaveNode::SlaveNode(const std::string &name) :
 	Node(name)
 {
+	server.state = SlaveNode::Server::NONE;
+
+	// server config (use explicit defaults)
+	server.local_address = "0.0.0.0";
+	server.local_port = 2404;
+	server.common_address = 1;
+	server.low_priority_queue = 100;
+	server.high_priority_queue = 100;
+
+	// config (use lib60870 defaults if std::nullopt)
+	server.apci_t0 = std::nullopt;
+	server.apci_t1 = std::nullopt;
+	server.apci_t2 = std::nullopt;
+	server.apci_t3 = std::nullopt;
+	server.apci_k = std::nullopt;
+	server.apci_w = std::nullopt;
+
+	// output config
+	output.enabled = false;
+	output.mapping = {};
+	output.asdu_types = {};
+	output.last_values = {};
 }
 
 SlaveNode::~SlaveNode()