source: rrlib_rtti/tTypedObject.h @ 51:853eefb63c79

Last change on this file since 51:853eefb63c79 was 51:853eefb63c79, checked in by Max Reichardt <mreichardt@…>, 5 years ago

Adapted remaining classes to our standard code template

File size: 3.7 KB
Line 
1//
2// You received this file as part of RRLib
3// Robotics Research Library
4//
5// Copyright (C) Finroc GbR (finroc.org)
6//
7// This program is free software; you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation; either version 2 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License along
18// with this program; if not, write to the Free Software Foundation, Inc.,
19// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20//
21//----------------------------------------------------------------------
22/*!\file    rrlib/rtti/tTypedObject.h
23 *
24 * \author  Max Reichardt
25 *
26 * \date    2012-02-05
27 *
28 * \brief   Contains tTypedObject
29 *
30 * \b tTypedObject
31 *
32 * This is the abstract base class for any object that has additional
33 * type information from rrlib_rtti.
34 *
35 */
36//----------------------------------------------------------------------
37#ifndef __rrlib__rtti__tTypedObject_h__
38#define __rrlib__rtti__tTypedObject_h__
39
40//----------------------------------------------------------------------
41// External includes (system with <>, local with "")
42//----------------------------------------------------------------------
43
44//----------------------------------------------------------------------
45// Internal includes with ""
46//----------------------------------------------------------------------
47#include "rrlib/rtti/tType.h"
48
49//----------------------------------------------------------------------
50// Namespace declaration
51//----------------------------------------------------------------------
52namespace rrlib
53{
54namespace rtti
55{
56
57//----------------------------------------------------------------------
58// Forward declarations / typedefs / enums
59//----------------------------------------------------------------------
60
61//----------------------------------------------------------------------
62// Class declaration
63//----------------------------------------------------------------------
64//! Object with type information
65/*!
66 * This is the abstract base class for any object that has additional
67 * type information from rrlib_rtti.
68 */
69class tTypedObject
70{
71
72//----------------------------------------------------------------------
73// Public methods and typedefs
74//----------------------------------------------------------------------
75public:
76
77  /*!
78   * \return Type of object
79   */
80  tTypedObject() :
81    type()
82  {}
83
84  virtual ~tTypedObject() {}
85
86  /*!
87   * \return Log description (default implementation is "<class name> (<pointer>)"
88   */
89  inline const tTypedObject& GetLogDescription() const
90  {
91    return *this;
92  }
93
94  /*!
95   * \ŗeturn Type information for object
96   */
97  inline tType GetType() const
98  {
99    return type;
100  }
101
102//----------------------------------------------------------------------
103// Protected fields and methods
104//----------------------------------------------------------------------
105protected:
106
107  /*! Type information for object */
108  tType type;
109
110};
111
112inline std::ostream& operator << (std::ostream& output, const tTypedObject* lu)
113{
114  output << typeid(*lu).name() << " (" << ((void*)lu) << ")";
115  return output;
116}
117
118inline std::ostream& operator << (std::ostream& output, const tTypedObject& lu)
119{
120  output << (&lu);
121  return output;
122}
123
124//----------------------------------------------------------------------
125// End of namespace declaration
126//----------------------------------------------------------------------
127}
128}
129
130
131#endif
Note: See TracBrowser for help on using the repository browser.