src/core/object-base.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sun, 16 Mar 2008 20:59:04 +0100
changeset 2634 44a92f1d3728
parent 2633 a0639de8cd8b
child 2637 ac94e4889027
permissions -rw-r--r--
introduce ObjectBase::GetInstanceTypeId

#ifndef OBJECT_BASE_H
#define OBJECT_BASE_H

#include "type-id.h"

/**
 * This macro should be invoked once for every class which
 * defines a new GetTypeId method.
 */
#define NS_OBJECT_ENSURE_REGISTERED(type)       \
  static struct X##type##RegistrationClass      \
  {                                             \
    X##type##RegistrationClass () {             \
      ns3::TypeId tid = type::GetTypeId ();     \
      tid.GetParent ();                         \
    }                                           \
} x_##type##RegistrationVariable

namespace ns3 {

/**
 * This base class is really used only to make sure that 
 * every subclass has RTTI information and that they all
 * share a single base class to allow us to make type 
 * checks across all these types.
 */
class ObjectBase
{
public:
  virtual ~ObjectBase ();
  virtual TypeId GetInstanceTypeId (void) const = 0;
};

} // namespace ns3

#endif /* OBJECT_BASE_H */