summaryrefslogtreecommitdiff
path: root/include/mts/MTS_Subscriber.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/mts/MTS_Subscriber.h')
-rw-r--r--include/mts/MTS_Subscriber.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/include/mts/MTS_Subscriber.h b/include/mts/MTS_Subscriber.h
new file mode 100644
index 0000000..e359d4c
--- /dev/null
+++ b/include/mts/MTS_Subscriber.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2015 by Multi-Tech Systems
+ *
+ * This file is part of libmts.
+ *
+ * libmts is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * libmts is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libmts. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/*! \file MTS_Subscriber.h
+ \brief An abstract subscriber
+ \date 28MAR12
+ \author Sean Godinez
+
+ A subscriber.
+ */
+#ifndef _MTS_SUBSCRIBER_H_
+#define _MTS_SUBSCRIBER_H_
+
+#include <mts/MTS_NonCopyable.h>
+#include <string>
+
+namespace MTS {
+
+ //! An abstract subscriber
+ /*!
+ A template abstract subscriber class
+
+ \sa Publisher
+ */
+ template<class T> class Subscriber: NonCopyable {
+
+ public:
+ virtual ~Subscriber(); //!< Destructs subscriber
+
+ const std::string& getName() const; //!< Returns name
+
+ virtual void update(const T& object) = 0; //!< Updates subscriber
+
+ protected:
+ explicit Subscriber(const std::string& name = ""); //!< Protected Constructor
+
+ private:
+ const std::string m_sName; //!< Name of subscriber
+
+ };
+
+ template<class T> Subscriber<T>::Subscriber(const std::string& name)
+ : m_sName(name) {
+ }
+
+ template<class T> Subscriber<T>::~Subscriber() {
+ }
+
+ template<class T> const std::string& Subscriber<T>::getName() const {
+ return m_sName;
+ }
+}
+
+#endif