]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- added const
authorArvin Schnell <aschnell@suse.de>
Thu, 26 Jan 2023 12:44:01 +0000 (13:44 +0100)
committerArvin Schnell <aschnell@suse.de>
Thu, 26 Jan 2023 12:44:01 +0000 (13:44 +0100)
zypp-plugin/zypp-plugin.cc
zypp-plugin/zypp-plugin.h

index b7027cd65a61e07dd9d66345b1f74f874def45df..2640337632a76287a3117bf0e5c6f0ac5178a824 100644 (file)
@@ -48,21 +48,8 @@ ZyppPlugin::main()
 }
 
 
-void
-ZyppPlugin::write_message(ostream& os, const Message& msg)
-{
-    os << msg.command << endl;
-    for (auto it: msg.headers) {
-       os << it.first << ':' << it.second << endl;
-    }
-    os << endl;
-    os << msg.body << '\0';
-    os.flush();
-}
-
-
 ZyppPlugin::Message
-ZyppPlugin::read_message(istream& is)
+ZyppPlugin::read_message(istream& is) const
 {
     enum class State { Start, Headers, Body } state = State::Start;
 
@@ -127,13 +114,23 @@ ZyppPlugin::read_message(istream& is)
 }
 
 
+void
+ZyppPlugin::write_message(ostream& os, const Message& msg) const
+{
+    os << msg.command << endl;
+    for (auto it : msg.headers)
+       os << it.first << ':' << it.second << endl;
+    os << endl;
+    os << msg.body << '\0';
+    os.flush();
+}
+
+
 ZyppPlugin::Message
 ZyppPlugin::dispatch(const Message& msg)
 {
     if (msg.command == "_DISCONNECT")
-    {
        return ack();
-    }
 
     Message a;
     a.command = "_ENOMETHOD";
index bbe8686019dd1ae119b4787305427cfa9c039a1a..cf51d05a772c6ff93e1f4bccfda53e1d08dba194 100644 (file)
@@ -56,15 +56,15 @@ public:
 
 protected:
 
+    Message read_message(std::istream& is) const;
+    void write_message(std::ostream& os, const Message& msg) const;
+
     /// Handle a message and return a reply.
-    // Derived classes should override it.
+    // Derived classes must override it.
     // The base acks a _DISCONNECT and replies _ENOMETHOD to everything else.
-    virtual Message dispatch(const Message& msg);
-
-    Message read_message(std::istream& is);
-    void write_message(std::ostream& os, const Message& msg);
+    virtual Message dispatch(const Message& msg) = 0;
 
-    Message ack()
+    Message ack() const
     {
        Message a;
        a.command = "ACK";