Runtime Type Information

Runtime Type Information

RTTI steht als Abkürzung für Runtime Type Information ("Typinformation zur Laufzeit"), ein Begriff aus der Softwareentwicklung und Bestandteil verschiedener Programmiersprachen.

RTTI ermöglicht es, zur Laufzeit den Typ eines Objektes zu ermitteln. Somit kann ein Programm während seiner Ausführung ermitteln, welcher konkreten Klasse ein Objekt angehört, auf das eine bestimmte Referenz zeigt. Ohne diesen Mechanismus "wüsste" das Programm an dieser Stelle nur, dass ein Exemplar irgendeiner Klasse referenziert wird, die von der Basisklasse abgeleitet ist. Mit diesem Mechanismus "weiß" es, welcher Klasse das referenzierte Objekt angehört.

Während RTTI einen recht einfachen Mechanismus darstellt, der üblicherweise nur den Namen der konkreten Klasse liefert, gibt es in moderneren Programmiersprachen den Mechanismus der Reflexion, der es ermöglicht auch Informationen über andere Eigenschaften einer Klasse zur Laufzeit zur ermitteln, z. B. die Namen und Signaturen ihrer Methoden.

Beispiel

Sei also z. B. die eine Referenz auf ein Exemplar der Basisklasse "Geschäftspartner" gegeben, von der zwei konkrete Unterklassen "Kunde" und "Lieferant" definiert sind. Mit Typinformation zur Laufzeit kann das Programm herausfinden, ob ein bestimmter Geschäftspartner ein Kunde oder ein Lieferant ist.

Besonderheiten

  • In Java wird die Typinformation zur Laufzeit durch die Methode "getClass" bereitgestellt, die eine Referenz auf ein sogenanntes Klassenobjekt zurück gibt, das unter anderem den Namen der konkreten Klasse kennt.
  • In Object Pascal steht einem der is-Operator zur Verfügung. Außerdem kann man ClassInfo, ClassType und ClassName eines Objekts abfragen.

Wikimedia Foundation.

Игры ⚽ Нужна курсовая?

Schlagen Sie auch in anderen Wörterbüchern nach:

  • Run-time type information — In programming, RTTI (Run Time Type Information, or Run Time Type Identification) refers to a C++ system that keeps information about an object s data type in memory at runtime. Run time type information can apply to simple data types, such as… …   Wikipedia

  • Runtime — In computer science, runtime or run time describes the operation of a computer program, the duration of its execution, from beginning to termination (compare compile time). The term runtime can also refer to a virtual machine to manage a program… …   Wikipedia

  • Type system — Type systems Type safety Inferred vs. Manifest Dynamic vs. Static Strong vs. Weak Nominal vs. Structural Dependent typing Duck typing Latent typing Linear typing Uniqueness typing …   Wikipedia

  • Type polymorphism — In computer science, polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface. The concept of parametric polymorphism applies to both data types and functions. A function… …   Wikipedia

  • Type safety — In computer science, type safety is a property of some programming languages that is defined differently by different communities, but most definitions involve the use of a type system to prevent certain erroneous or undesirable program behavior… …   Wikipedia

  • Type inference — Type inference, or implicit typing, refers to the ability to deduce automatically the type of a value in a programming language. It is a feature present in some strongly statically typed languages. It is often characteristic of but not limited to …   Wikipedia

  • Common Type System — In Microsoft s .NET Framework, the Common Type System (CTS) is a standard that specifies how Type definitions and specific values of Types are represented in computer memory. It is intended to allow programs written in different programming… …   Wikipedia

  • Enumerated type — In computer programming, an enumerated type is a data type (usually user defined) consisting of a set of named constants called enumerators . The act of creating an enumerated type defines an enumeration. When an identifier such as a variable is… …   Wikipedia

  • RTTI — Runtime Type Information …   Acronyms

  • RTTI — Runtime Type Information …   Acronyms von A bis Z

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”