1. Introduction

1.1 Definition

1.2 Motivation

1.3 Architecture

2. Concept

2.1 Look & Feel & Layout management

2.2 Messaging System

2.3 Multiple inheritance and AbsoluteX event handling

2.4 LibSigc++ library

2.5 Signal & Slots

3. Standards

3.1 STL

3.2 Xlib

4. Features

5. Class Groups

6. Widgets set

Appendix A - Multiple Inheritance

Appendix B - Features of LibSigC++ (Signals)

Appendix C - QT Versus LibSigC++

 

1. Introduction

1.1 Definition

AbsoluteX is an open source, free class library developed, primarily, for use with the X-Window System.

AbsoluteX, from the object-oriented design to its free software LGPL licensing, allows you to code your project with the greatest possible freedom.

With AbsoluteX, you can develop open software, free software, or even commercial non-free software, without having to spend money for licenses or royalties.

1.2 Motivation

We felt that there was a need for a flexible Look & Feel for the desktop task bar and other applications. Moreover, we wanted to use libraries that have proven to be stable, documented and facilitate a fast learning curve.

After assessing the existing tool-kits and libraries, we arrived at the conclusion that the existing toolkits and libraries did not support our needs. To address this problem, we created AbsoluteX.

It is our belief that creating a class library based on multiple inheritance and templates would allow programmers to use the library more efficiently. Such a streamlined library would not contain collection classes for data structures (like a list, a map etc.), as their standards have already been set by STL.

We believe that no other alternative method of using the existing tool kit is possible, without eliminating their legacy.

1.3 Architecture

AbsoluteX is an Xlib based class library. It is a C++ encapsulation for the Xlib API. In order to use AbsoluteX the following environment elements are required:

  • X11R6 or Higher - a graphical windowing system with a unique device-dependent architecture that supports the development of portable graphical user interfaces. X-Window is included in most UNIX machines as part of their operating system.
  • STL - a C++ library that provides a set of C++ container classes and generic algorithms
  • LibSigC++ - library implements a full callback system for use in widget libraries, abstract interfaces, and general programming. Originally part of Gtk--widget set, LibSigc++ is now a separate library to provide for more general use.
    http://libsigc.sourceforge.net/
  • Imlib - a C library designed for image loading and obtaining X-Windows graphics.

2. Concept

When developing applications, the trend is to ensure that it will be possible to easily and dynamically create a unique Look & Feel.

In contrast, the available tool-kits for X and Windows platforms are complex and hard to manipulate and maintain. Moreover, they do not provide adequate support for performing tasks. In the absence of an appropriate toolkit, the developer is forced to resort to endless workarounds.

2.1 Look & Feel & Layout management

Epitera’s vision is to establish a state-of-the-art C++ class library, offering the most updated programming methods that separate logic and visual aspect.

  • Logic - In order to ensure the stability of the application, logics are determined at compilation time.
  • Visual aspect - UI & Graphics provide a layout (XML based resource) and graphics elements, such as buttons, scroll-bars and lists, which can be set dynamically at run time.

This dynamic layout supports the possibility of gaining a perspective as to how the Look & Feel of the application will appear in different window sizes.

Important features that are integrated into AbsoluteX libraries are:

1) Increased Graphics freedom - by providing general anti-liaising support

2) Override visual functions capability - a new approach aimed at attaining special UI

We have created a library design that allows the developer to override all visual functions and to achieve a special UI. A developer, for example, can override the list view control item.

2.2 Messaging System

AbsoluteX uses an intuitive and efficient event handling approach. Unlike other libraries, where all events are sent to a window at runtime, an AbsoluteX window receives only the events required, giving greater efficiency at runtime and a simpler interface for the developer.

The AbsoluteX approach relies on two main features:

1) Multiple inheritance design

2) LibSigc++ signal and slot library

2.3 Multiple inheritance and AbsoluteX event handling

When using the multiple inheritance approach, the window interface remains "clean", with no events. This leaves the window free to handle window properties and methods only, thus creating a simple interface for the programmer.

An event, or event group, is handled with a specific event handler that is inherited from the event handler class in conjunction with a user AbsoluteX window.

An AbsoluteX event handler holds only the methods and signals that it uses. The result is a high abstraction level and improved efficiency because this mechanism takes advantage of the X-window system ability to allocate events to windows. This feature facilitates developing by allowing the developer to select only those events that he needs.

The following steps are used to handle events in AbsoluteX when overriding the virtual method in the event handler:

1) Make your window both an xppWindowBase subclass at some points on the inheritance tree and a subclass of the event handler.

2) Override the virtual method in the event handler class, or use the signal (see 2.4).

For more information on Multiple Inheritance, see Appendix A.

2.4 LibSigc++ library

The Virtual method overriding technique is not applicable for all purposes.

If, for example, there is a button in our main window that has been declared a member data, overriding the "click" event involves creating a subclass of xppButton and having this subclass declared as a member data also. This will lead to load numerous classes on each application and generate maintenance problems.

The convenient and right way will be creating, for example, a dialog box that handles all the application's logic in the dialog class while maintaining the widgets as simple widgets.

For this reason AbsoluteX uses the LibSigc++ library.

LibSigc++ (SigC for short) is an advanced and very efficient C++ implementation of the signal and slot mechanism.

SigC is an open source project that is already being used in other class libraries. SigC has shown that it has been properly designed; it is stable and very efficient.

For more information about signals and slots, please visit the SigC homepage, hosted at sourceforge at: http://libsigc.sourceforge.net

2.5 Signal & Slots

Every AbsoluteX event handler has a corresponding signal as a public member for each virtufunction. For example, the OnKeyPress method has a corresponding signal called signal_KeyPress.

In order to connect, the developer has to declare the class receiving the signals as a subclass of SigC::Object, and to connect to the slot on the receiving class.

A developer may want to create a subclass of a button that makes a sound when clicked and have all the actions themselves applied to the signals received in some other code segment.

3. Standards

3.1 STL

The Standard Template Library is a C++ library that provides a set of easily composable C++ container classes and generic algorithms (template functions).

The container classes include vectors, lists, deques, sets, multisets, maps, multimaps, stacks, queues and priority queues.

The generic algorithms include a broad range of fundamental algorithms for the most common kinds of data manipulations, such as searching, sorting, merging, copying, and transforming.

STL uses iterators that generalize C++ pointers as intermediaries between algorithms and containers. Another difference is that most STL algorithms are generic, therefore they work on different containers and even on C++ arrays. By creating a classification of iterators into categories, it is possible to determine which algorithms can be used with which containers. By classifying the iterators, it is possible to extend the library to include new algorithms that work with STL containers, or new containers to which STL generic algorithms can be applied.

3.2 Xlib

One of the goals of the Xlib project is to create a common base, written in Xlib, which will include all the functionality that is common across Linux toolkits.

In Xlib it is possible to implement internationalization without the support of the toolkit as much of the infrastructure for this purpose is already in place.

 

 

 

4. Features

Full Xlib encapsulation

Encapsulation relates to the use and understanding of Xlib. An intuitive straightforward structure was developed to simplify the work of the programmers.

Built in free form skinning

Programmers no longer need to get bogged down developing the layout and graphics design. This is left to the expert. The layout and design can be easily changed at run time by replacing resources.

XML Layout

Layout can be set by using XML, the standard for representing resources.

Signal & Slots \ LibSigC++

This is a simple and effective method of communication between the object-like button and container. This method enables the sophisticated use of the library by utilizing powerful and new C++ programming methodologies, like template classes and function objects.

STL based

Programmers do not need to learn new collection classes and can use STL, the standard for lists, maps, vectors, etc.

Multiple inheritance oriented

This orientation increases the efficiency of the library and simplifies the interfaces.

Template oriented

This feature offers templates containing generic code that can be used for a wide variety of usages.

 

5. Class Groups

We can distinguish between several class types, each of which can be divided into the following groups:

Core & Miscellaneous - basic classes that encapsulate X structures and provide other required basic elements. These group include classes like application, point, size, dimension, reference counting etc.

X Server objects - the encapsulation of various X-server objects and functions, including drawables, such as pixmaps, windows and attributes, such as graphics context, fonts, colors etc.

Handlers - classes which handle groups of events defined in the X. These group include classes, such as key handlers, button handlers, configure, notify etc.

Layout - sets of classes that help determine position and behavior, when widgets and background elements are resized. These group include classes, such as table layouts, line layouts etc.

Widgets - reference classes for various controls, such as buttons, labels, lists.

6. Widgets set

Button - a simple graphic button that has states, where a special face can be set for each state.

Button Group - used for grouping button widgets together, usually radio buttons, and checkboxes. Frames and header texts are options.

Label - represents static text implemented for a variety of uses, such as for labels on dialogs, menu items etc.

List - displays tabular data in various views: Icons, Lists and free positions.

Menu - displays and manages a pop up or a pull down menu for selection. Since the menu is written as a template, it can be any visible type, such as a label, button text, edit etc.

Radio button - a button for displaying an exclusive option, together with an explanatory label. The label may be a text or a pixmap. Supports both binary on/off mode and tri-state on/grayed-out/off mode.

Scroll bar - horizontal and vertical scroll bars are available for scrolling content that does not fit into the available area.

Spin buttons - two buttons that support both the scrolling functionality and the mouse wheel. These buttons can be laid separately.

Tool tip - a tip that pops up whenever the mouse cursor rests over the widgets for a predefined amount of time.

Note: Now, at the second phase of the project we are designing a larger widgets set that will have a wider range of possibilities.

 

Appendix A - Multiple Inheritance

1. Inheritance

Inheritance is an abstraction that enables similarities to be shared by classes. At the same time, it is possible to specify the unique features of the various classes without eliminating the features that are shared. Inheritance has a definite direction - classes inherit the features of their ancestors and pass their own features on to their descendants. Theoretically, there can be any number of levels of inheritance.

2. Abstraction

Abstraction has been defined as "the selective examination of certain aspects of a problem." In essence, abstraction represents the attempt to separate important elements of a system from those that are irrelevant. The abstraction can then be examined with the aim of better understanding the underlying reality. Subsequently, a model can be created that would provide guidelines for implementation.

One of the unique advantages of Object Modeling is that it makes the results of the analysis more relevant to the implementation stage, by providing feedback to the model in a constructive manner.

Within the scope of inheritance, generalized super classes are an abstraction that allows shared features. A super class allows the creation of standard methods and attributes that apply to all sub classes, where a class that contains no instances is referred to as a Virtual Class.

It is not rare to encounter many levels of Virtual Classes above an implementation class. The structure of the inheritance tree does not have to be objective. Both the inheritance tree and the pertinent abstract classes depend on the particular requirements of the system.

3. Multiple Inheritance

Multiple inheritance is a more complex form of generalization. Multiple inheritance reflects the capability of a class to inherit features from more than one super-class. The features of the super classes are inherited by the subclasses. Although, theoretically, when the same feature is present in more than one super class it is only inherited once, in practice, conflicts can arise when implementing methods between super-classes.

4. Advantages and disadvantages of Multiple Inheritance

Advantages

Multiple Inheritance allows complex relationships to be modeled. It allows unusual classes to be incorporated within an existing framework. For example, a camping trailer has the features of both vehicle and house.

Single inheritance can be limiting, especially in respect to classes that cannot be classified into any of the branches of the class tree. Rather than creating a new abstract class containing only one sub class or forcing the class into an existing category, the multiple inheritance technique enables the developer to combine features from different super classes. This allows such anomalous classes to be incorporated into the hierarchy.

Disadvantages

Not all object oriented programming languages support multiple inheritance. Thus, whenthe implementation language does not support multiple inheritance, a workaround is required. This complicates the process of translating the design to its implementation.

Multiple inheritance may introduce conflicts between attributes and method names between ancestors. Different languages handle such conflicts in different ways. Whereas some languages resolve such problems automatically, others produce compile time errors. This can cause problems when adding a new class, especially when changing the inherited class declarations.

 

Appendix B - Features of LibSigC++ (Signals)

The following features characterize LibSigC++:

  • Compile time typesafe callbacks (faster than run time checks)
  • Typesafety violations report the correct line number, specifying the template name (thus avoiding tracing the template failures to the headers)
  • No compiler extensions or Meta compilers required
  • Proper handling of dynamic objects and signals (preventing seg faults by deleted objects)
  • Extendable API at any level Slot, Connection, Object, and Signal.
  • Use of extensions without altering basic components
  • User definable marshallers.
  • Provides headers for up to 7 arguments and 2 callback data elements
  • Provides M4 Macros to build templates containing arguments and callback data
  • Provides support for templates that are easily built, using arguments
  • Callback data not defined in library headers

 

The reference is Libsigc++ home page at: http://libsigc.sourceforge.net/benchmark.html

 

 

Appendix C - QT Versus LibSigC++

1. Similarities and Differences Between QT and LibSigc++

Differences

  • Different design goals
  • Qt = excellent widget set and program framework.
    Libsigc++ = a small component.
  • Qt was written several years ago (Trolltech is considered with binary compatibility with old versions) while it is possible to fix failings during testing of Libsigc++.
  • Architecture - Libsigc++ is a template library ( all the code is specialized for each usage ) while Qt is a generalist using strings to store all signal information ( flexible but slower ).

Similarities

  • Both provide similar functionality with their signal/slot system
  • Both are C++ libraries which run under windows & Unix
  • Both originated from widget sets
  • Both have flexibility and ease of use of key factors

 

Table of features:

Feature

Qt

Libsigc++

Comments

Special compiler steps

Yes

No

Qt must provide support for early compilers that have poor template support

Protected signals (refer to the access of a signal in a class)

Yes

Yes

Qt can emit from inside the owning class

Public signals (“)

No

Yes

LibSigc++ signals are normal objects, thus can fit all.
Proper handling of dynamic objects and signals (deleted objects will not cause seg faults)

Any function can be slot

No

Yes

 

Void returns (these refer to what type a signal may return from emit)

Yes

Yes

 

Non-void returns (“)

No

Yes

 

Any type in argument list (There can be some restrictions on the number and type of arguments a signal can take)

No

Yes

Qt doesn’t support templates or function pointers in argument lists

Signals in global scope

No

Yes

LibSigc++ signals can be declared anywhere.

Signals in class scope

Yes

Yes

Extendable API at any level Slot, Connection, Object, and Signal

Signals in other scopes

No

Yes

Extendable API at any level Slot, Connection, Object, and Signal

Bind able arguments and converting types

No

Yes

 

Argument type conversion

No

Yes

 

Return type conversion

No

Yes

 

Namespace support

No

Yes

 

Signal cost (bytes)

0

4

Qt is the clear winner.

It can be achieved in LibSigc++ with a specialized signal and a map, but it will be slower.

Thread safe marshalling

No

Yes

Marshaller is a structure which gathers up the results of a multi-callback to return a single return value.

 

The reference is Libsigc++ benchmark page at: http://libsigc.sourceforge.net/benchmark.html