summaryrefslogtreecommitdiff
path: root/include/mts/MTS_Subscriber.h
blob: e359d4c700925712912d0aa5e159f70abc8b3a92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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