opC++ Features

opC++ Compiler

opC++ Language

opGames Company

Reflection

opC++ Reflection

Reflection in a language means that you can get information about classes in your program at run-time. It gives you the ability to iterate over an object's data and methods, without needing to know the exact class you're dealing with.

Reflection is also often accompanied by descriptive metadata which give you additional information about data members. For example, whether or not a data member is saved to disk may be indicated by metadata.

Previously only available in non-standard C++ and other languages, opC++ adds Data Reflection and Metadata capabilities to Standard C++, opening whole new possibilities to C++ and levels of performance previously unattainable with Reflection.

Reflection in C++ ? ! ?

Thats right, type-safe access to data reflection.

No libraries.

No platform constraints.

Reflection is generated as a parallel structure alongside opstructs and opclasses - this additional code and data is used statically and at compile time. All operations occur in static memory or on the stack, so costs from Reflection in opC++ are entirely predictable.

By avoiding dynamic memory, opC++ Reflection is able to achieve uncompromising performance!

Reflection Speed

opC++ Runtime Data Reflection is over 17x faster than cached C# Reflection. Even using cached C# Reflection.Emit accessors doesn't come close to opC++ Reflection's performance.

With opC++ you also have the option to generate code directly in some cases, bypassing reflection at compile time with custom dialects.

Reflection In opC++

There are several different ways to use reflection in opC++:

  • External reflection - reflection information about a type without any instances. quick tutorial
  • Instance reflection - reflection on a particular instance of a type. quick tutorial

The basic concepts in opC++ Reflection are:

  • Types - give you information about a type, such as its name, inheritance, and fields.
  • Fields - give you information about a particular data member in a Type.
  • Accessors - give you easy abstracted access to data.
  • Visitors - give you fast access to Accessors.

opC++ gives you access to reflection through a visitor pattern. Data may be accessed by passing visitors to an opclass, or by externally visiting a particular field. By using visitors as a building block, you can generate faster cached structures, or use visitors directly to perform type-safe reflection entirely on the stack.

Detailed documentation on the opC++ Reflection can be found here.

STL Reflection

opC++ Reflection supports all basic STL containers, including:

  • single element containers: vector, deque, list, set, multiset.
  • pair element containers: map, multimap.
  • basic types: string, pair.
  • ability to extend support to user defined containers.
  • categorized types, for adding new types that work with existing visitors.

You can discover the type of a container using reflection accessors.

You can also manipulate container data without knowing the true type of a container.

STL Direct Cast

opC++ supports accessing STL containers using abstracted types, and gives you direct access to containers.

opC++ supports type-safe casting from reflection directly to STL container types and any other reflected types, all without the use of RTTI.

Recent Changes (All) | Edit SideBar Page last modified on December 21, 2007, at 03:43 PM Edit Page | Page History
Copyright 2010 opGames Inc.