Open Source‎ > ‎

ROOT GSoC Proposal

Modern C++ updates to ROOT Classes
Last Updated: 27th March, 16:08 UTC.

Organization: CERN SFT

Abstract: In this project, modern C++ standards will be implemented to ROOT classes. The new updates include allowing move semantics, extending and updating copy constructors, using initializer lists, controlling implicit conversion, using delete and default specifiers, overloading more operators for iterators, allowing range-based for loops, and smart pointers.

Proposal Contents:

1. Project at a glance
2. Project goals
3. Analysis and implementation details
4. Tentative timeline
5. About me
6. Link for more details


1. Project at a glance:

In this project, modern C++ standards will be implemented to ROOT classes. The new updates include allowing move semantics, extending and updating copy constructors, using initializer lists, controlling implicit conversion and suppressing unnecessary constructors using the delete keyword. The updates will involve also the iteration over collections such as hash-tables, maps and lists by overloading operators for the underlying iterators and allowing range-based for loops. Smart pointers will be partially used to relieve the burden off the developers to manage some dynamic data returned by member functions.


2. Project Goals:

2.1. Make use of modern C++ standards to perform tasks and optimize the ROOT classes.

2.2. Make sure that construction/destruction process of classes is safe and efficient.

2.3. Allow searching for, operating on and removal of objects in collections using predicates and functors.

2.4. Update the iterator classes and overload more iterator operators.

2.5. Allow range-based for loops over collections such as lists.

2.6. Integrate C++ STL algorithm library into ROOT.

2.7. Overload some pointer-returning functions to return smart pointers to avoid memory leaks and relieve the burden off the developer.

2.8. Implement other relative miscellaneous updates.


3. Analysis and implementation details:

The goal of this project is to modernize ROOT by making it up-to-date with modern C++ standards.


3.1. Move Semantics

By scanning ROOT documentation, it is found that only a few classes implement the move constructor. Move constructors provide an efficient way to deeply copy objects that before they run out of scope. One of this project goals is to make sure that move semantics are implemented whenever appropriate.

3.2. Constructors and conversion

This milestone of updates aims at maintaining constructors/destructors of existing classes. The goals are to determine which constructors will be useful for a class, importance of having copy, move constructors, assignment and/or conversion operators. Also, for each class, we should decide on their access and explicit specifier to guarantee safe construction. Sometimes it is more convenient to let constructors and type conversion be explicit to avoid ambiguous implicit type conversion or weird construction of objects. Additionally, if it is necessary, some default constructors may be suppressed or forced using the delete and default keywords to make sure the compiler will not generate them.

3.3. Initializer list

One of the powerful features that were emphasized in C++11 is the use of initializer lists in construction of objects.

Allowing constructors to be passed initilizer lists provides dynamic control over how to initialize an object. For example, collections like TList and TMap may be given some initial elements to be pushed. The count of these elements is not statically(at compile time) determined. An initliazer list would be the best way to accomodate dynamic emplacement of elements into lists, hash-tables or maps during construction specially if the data type is primitive.

Additionally, initializer lists can allow dynamic inference of object type. For example, we may have a function that returns a pointer to some generic TEveVector while the underlying object is determined based on how many parameters are passed in the initializer list. Some functions like make_vector() will be implemented that takes an initializer list without knowing its count and infer whether to make 2D, 3D ..etc vector.

3.4. Iteration

3.4.a. Operator overloading in iterators

This update will involve iterator classes like TEventIterTListIter,...etc. The updates include modifying the member functions to be more consistent with the way STL iterators work. For example, using the ++ operator in advancing an iterator is more handy than using a Next() member function.

3.4.b. Range-based for loops

One of the powerful syntactic aids introduced in C++11 is range-based for loops. This new syntax of for-loops allows iterating over ranges and containers without redundant typing and with more control. Introducing this to ROOT classes specially containers like TList and TMap would require defining begin() and end() member functions to containers and adapting existing iterators to make sure they will be go in harmony with range-based iteration. One of the adaptations is the one described in part (a).

3.5. Predicates and lambda expressions

One of the powerful features of C++ is the use of Lambda expressions to define on-the-go functions and predicates. Allowing developers to pass predicates or Lambda expressions to member functions will facilitate the process of finding, comparing, deleting elements and many other tasks.

Consider the set of functions FindObject(), DeleteEntry() and RemoveEntry() which are members of a number of ROOT classes such as TMapTList and THashTable. Adding find_if(), delete_if() and remove_if() methods to these classes similar to those in C++ standard library would allow the user to pass predicates that will search for, delete or remove elements based on the criteria they define. 

Additionally, containers may have a function like performOperation() that takes as parameters a range to perform on or a predicate determining the selection criteria and a functor determining what operation to execute on the matching objects.

3.6. Integration with C++ algorithm library

After updating the iterators and allowing the use of range-based for loops, it would be advantageous to make use of the C++ algorithm library to do common tasks like for instance sorting a TList or doing replace_if() on a collection.

3.7. Miscellaneous updates

More deep analysis will be done investigating member functions to determine possible syntactic updates that may be inserted to improve code re-usability and efficiency.

For example, by investigating the TMap class's RemoveEntry() member function, it is found that it makes the developer responsible for cleaning the TPair object after using it. Some overloads to this function may be written using smart pointers that would destruct the object automatically on getting out of a specific scope.


4. Tentative Timeline:

I will finish my spring semester on 27th May. I will be fully dedicated during the summer vacation to the GSoC project with around 8 hours/day for five days a week (40hrs/week). Here is a tentative schedule of the project. I am also ready to write frequent blog posts documenting what I do.


Tentative Project Schedule
Community Bonding Period:
April 27th - May 27th
-Getting to know the CERN SFT community
-Exploring ROOT in depth
Week 01: 27th May - 3th June-Examining ROOT Classes
-Preparing a report of planned updates
Week 02: 3rd June - 10th June

-Updating constructors and move semantics
-Explicit/implicit constructors and type-conversion

Week 03: 10th June - 17th June-Allowing use of initializer lists
-Flexible dynamic object allocation
Week 04: 17th June - 24th June-Unit testing for efficiency of constructors and fixing bugs
-Documentation of updated constructors
-Adding examples and/or tutorials
Week 05: 24th June - 1st July-Planning updates on collections' iterators
-Updating iterators
-Unit testing of updated iterators and fixing bugs
-Documentation, adding examples and/or tutorials
Week 06: 1st July - 8th July-Allowing lambda expressions, functors to find, delete and
-operate on collections' elements
Week 07: 8th July - 15th July-Integrating range-based for loops to appropriate collections
-Unit testing for the built iteration modules
-Fixing bugs
-Preparing Documentation, tutorials and examples
Week 08: 15th July - 22nd July-Integrating C++ STL's algorithm library to containers
Week 09: 22nd July - 29th July-Finish integration of C++ STL's algorithm library
-Testing and fixing bugs
-Documentation, tutorials and examples
Week 10: 22nd July - 29th July-Integrating smart pointers
-Scanning for and planning for miscellaneous updates
-Miscellaneous updates include updates
to how member functions operate internally
Week 11: 29th July - 5th August-Continue with miscellaneous updates
Week 12: 5th August - 12th August-Continue with miscellaneous updates
-Finish anything remaining
-Finalize testing, documentation for the miscellaneous updates
Week 13: 12th August - 19th August-Fixing any bugs
-Review Documentation
-Shipping Code
Pencils Down: 21st August-Firm Pencils Down: Project wrap up

5. About Me:

Name: Islam Faisal Ibrahim
University: The American University in Cairo
Major: Computer Science and Mathematics
Contact email: islamfm@aucegypt.edu
Website: decltypeme.i2msoft.com

Short Bio:

I am an undergraduate student double majoring in computer science and mathematics. I worked as an undergraduate teaching assistant since my first semester at college. I spent the summer of 2014 at Nile University where I worked as a summer trainee on machine learning at the Ubiquitous & Visual Computing Group (UbiComp).

Why I believe I match this project?
I have been working with C++ software development for more than two years. I used C++ in various academic projects and during my previous internship at Nile University. I took a course in Object-Oriented Programming, C++11 and socket programming in Fall 2014. I worked as an undergraduate teaching assistant for a data structures and algorithms course in C++. I have basic knowledge of ROOT, its classes and how it works.

My detailed CV:
decltypeme.i2msoft.com/cv
My academic courses:
decltypeme.i2msoft.com/education


6. More details:

For more details about the project, any updates or thoughts that I may add to the project, they will be added to this webpage.
http://decltypeme.i2msoft.com/open-source/root-gsoc-proposal

Comments