Seal Dictionary Applications Area Internal Review 20 October 2003 Stefan Roiser / CERN.

12
Seal Dictionary Applications Area Internal Review 20 October 2003 Stefan Roiser / CERN

Transcript of Seal Dictionary Applications Area Internal Review 20 October 2003 Stefan Roiser / CERN.

Page 1: Seal Dictionary Applications Area Internal Review 20 October 2003 Stefan Roiser / CERN.

Seal Dictionary

Applications Area Internal Review20 October 2003Stefan Roiser / CERN

Page 2: Seal Dictionary Applications Area Internal Review 20 October 2003 Stefan Roiser / CERN.

20 October 2003 Seal Dictionary 2

Motivation

The Architecture Blueprint RTAG proposes the use of object dictionaries for– object streamers, object browsers, debuggers– rapid prototyping applications (e.g. Python)– runtime discovery of interfaces

Modern languages provide reflection inherently– In C++ reflection is very limited (RTTI)

The basic C++ concepts shall be supported– e.g. inheritance, methods, data members,

accessibility, templates

Page 3: Seal Dictionary Applications Area Internal Review 20 October 2003 Stefan Roiser / CERN.

20 October 2003 Seal Dictionary 3

Packages in Seal Dictionary

Reflection packages– DictionaryGenerator for producing sources– ReflectionBuilder, the loading interface– Reflection, the user API

Dictionary examples– CMS– ATLAS (not yet in cvs)

Standard Dictionaries– CLHEP: Random, Vector– STL: Vector, List, String– Dictionary: Reflection

Page 4: Seal Dictionary Applications Area Internal Review 20 October 2003 Stefan Roiser / CERN.

20 October 2003 Seal Dictionary 4

Overall View

Dictionary forC++ Object

ReflectionSystem

Client

C++ Object

• Build dictionary for C++ object

• Load information about the object into the reflection model

• Provide meta information about the object to the user

Page 5: Seal Dictionary Applications Area Internal Review 20 October 2003 Stefan Roiser / CERN.

20 October 2003 Seal Dictionary 5

Reflection Model Class Diagram

PropertyListItem

MethodField

ItemBuilder

MethodBuilderFieldBuilderClassBuilder

NamespaceBuilder

Reflection

ReflectionBuilder

ClassNamespace

Page 6: Seal Dictionary Applications Area Internal Review 20 October 2003 Stefan Roiser / CERN.

20 October 2003 Seal Dictionary 6

Usage Example

Class mc* = Class::forName(“Foo”);void* fooInst = mc->instantiate();

std::vector<Field*> fields = mc->fields();std::string f0name = fields[0]->name();std::string f0type = fields[0]->type()->name();fields[0].set(fooInst, 4711);

Method* m0meth = mc->method(“getBar”);int m0val = m0meth->invoke(fooInst);

Page 7: Seal Dictionary Applications Area Internal Review 20 October 2003 Stefan Roiser / CERN.

20 October 2003 Seal Dictionary 7

Parse C++ Header Files

gccxml.h .xml

_dict.cpp

.xml

parserfilter +extend

gendict

make dict.so

lcgdict

Example: lcgdict Foo.h –-select=FooSel.xml --deep –I/home/lcg/include

selection file

header file

dictionary source dictionary library

.xml

GODdesc

Page 8: Seal Dictionary Applications Area Internal Review 20 October 2003 Stefan Roiser / CERN.

20 October 2003 Seal Dictionary 8

How to build Dictionaries

Parse C++ header files– lcgdict

» i.e. gccxml + python script

Other means– Derive from XML

descriptions» LHCb approach

– Write by hand» design was made

with simple syntax in mind

#include “Foo.h”

class Foo_dict {public: Foo_dict();};

Foo_dict::Foo_dict() {ClassBuilder(“Foo”,”desc of Foo”, typeid(Foo),sizeof(Foo)).addField(“bar”,”int”,”desc of bar”, OffsetOf(Foo,bar)).addMethod(“getBar”,“desc of getBar”, “int”, Foo_getBar).build(); }

static Foo_dict inst;

Page 9: Seal Dictionary Applications Area Internal Review 20 October 2003 Stefan Roiser / CERN.

20 October 2003 Seal Dictionary 9

Who is using Dictionaries

POOL– DataService

»Casting, type-checking and deleting of objects– StorageService

»Provide meta-information of objects when writing» Instantiating objects when reading, type-

checking SEAL

– PyLCGDict»Python gateway to dictionaries

– PluginManager (work in progress)»Loading dictionaries into the application

Page 10: Seal Dictionary Applications Area Internal Review 20 October 2003 Stefan Roiser / CERN.

20 October 2003 Seal Dictionary10

New Reflection Model

Inheritance

PointerReferenceArrayFunctionFundamental

Type

Scope

Namespace

Member

PropertyList

Reflection

TypeDef Class Enum

Page 11: Seal Dictionary Applications Area Internal Review 20 October 2003 Stefan Roiser / CERN.

20 October 2003 Seal Dictionary11

Outlook

Implementation of new model Extending and creating new dictionaries on

demand eXtended Type Information (XTI)

– Stroustrup approach– Still very preliminary, solution for far future

New language gateways– Java gateway under investigation

Page 12: Seal Dictionary Applications Area Internal Review 20 October 2003 Stefan Roiser / CERN.

20 October 2003 Seal Dictionary12

Summary

Seal– Provides standard dictionaries (STL, CLHEP, …)– Provides python gateway (PyLCGDict)– Feasibility studies for ATLAS and CMS– PluginManager will load dictionaries – New model will be implemented soon

Pool– Has been using dictionary system from the

beginning LHCb

– Will use dictionaries as well