TracNav
Overview
- Introduction
- Credits and Contributors
Zen Core
Zen Engine
Zen Enterprise
Miscellaneous
Contents
Zen :: Core
Zen Core is the foundation of the rest of Zen Open Source Software (ZOSS).
It is written in pure ISO C++ and relies only on Boost, and libxml2 libraries.
It contains a smart pointer memory management library, a template based event library, a math library, a plugin system, a scripting framework, a threading library and a utility library.
Memory Manager
The Memory library in Zen Core is a set of templates that provides application developer with a reference counted smart pointer that works well with class factories.
Through the use of class traits, you can easily define whether a class is managed by a factory or by standard new / delete semantics, as well as set the threading trait.
Many of the ZOSS libraries make extensive use of this library, as it improves the efficiency of applications by making it easy to create object pools. It also makes memory leaks a thing of the past, just as Java, C# and many other "garbage collected" langauges.
Essentially, this library provides a type of automatic garbage collection for C++.
Event System
The Event library in Zen Core is a multicast thread safe event system. This library provides easy to use publish / subscribe semantics with an extremely efficient template based implementation.
Math Library
Zen Core's Math library contains implementations for a variety of math classes useful for 3d math. The math clasess include classes for matrices, vectors, points, quaternions, degrees and radians.
Plugin System
The bulk of the implementation within Zen Core exists in support of the Plugin System and the related registries.
Plugins are components inside of shared libraries (DLL or SO, depending on your platform). These components are dynamically loaded at runtime on demand.
The Plugin System registry stores information about the different components that can be loaded. Applications can interrogate the plugin registry, find a component that it needs to load, then load it dynamically at runtime.
Zen Core achieves this through concepts called Extensions and Extension Points.
Extension Points
An Extension Point is a place within the framework which can be extended.
It consists primarily of a definition inside of an XML file, plus an abstract interface that defines what the extension point should do.
Extensions
An Extension is an implementation of an Extension Point that does the extending. In other words, it is the concrete implementation of the abstract interface deefined in the Extension Point.
How it works
An Extension Point is defined through the use of four pieces of code. An interface, an abstract factory, a manager and an XML schema.
First is the Interface, which is defined through an abstract C++ class, generally called a Service. This interface defines what the Extension Point can "do". For example, "I_RenderingService" defines a Rendering Extension Point, and the abstract methods (virtual xxx() = 0) define what a Rendering Extension Point can do.
The second piece of an Extension Point is an abstract Factory. The abstract Factory defines how an Extension Point Service is created. Since it's abstract, the factory doesn't really create anything because the only implementation is the constructor and the destructor, which are generally empty.
The third piece of an Extension Point is a manager. The manager of an extension point generally is a singleton helper class that implements the interaction between the extension point and the Zen Core Plugin System.
The last piece of of an Extension Point is actually coded in XML. A portion of the XML defines the namespace, the service name and the location of a schema. The namespace and service name defined in the XML generally corresponds with the C++ namespace and interface name of the extension point Service, minus the "I_" portion. Using our previous example of the Rendering extension point, I_RenderingService is in the "Zen::Engine::Rendering" namespace, so inside the extension point XML, the namespace is declared as "Zen::Engine::Rendering" and the service name is "RenderingService?".
The schema to which the XML points is a schema used as the meta data that defines what type of information is required when defining an Extension that implements the Extension Point.
In Zen Core, the bulk of the abstract classes are related to creating plugins and most of the interactions among the interfaces are rather vague, but their's a good reason for this.
Zen Core is a framework framework. The sole purpose of the framework is to make it easier to create other frameworks.
Scripting Framework
Also included in Zen Core is a scripting framework. This framework makes it easier for you to integrate scripting languages into your application.
Using the framework, you define scriptable classes, object and methods in a generic way. Scripting plugins utilize this information and implement the "glue" code that does the actual C/C++ binding to the script library.
Currently Lua and Python scripting libraries have been implemented, making it so that with very little code you can easily create applications that bind to either (or both) of those languages. Adding new languages is simple, and as new scripting plugins are created, your applications using the scripting framework will already be capable of using the additional languages.
Threading Library
The Threading library is a cross platform object oriented C++ library that implements classes for threads, mutexes, condition variables, thread safe queues, thread pools and more.
Utility Library
The Utility library is barely worth mentioning, but I'll mention it for completeness. This is where we place helper classes that don't generally fit with any of the other libraries.
What is a Framework?
What are frameworks? We hear the term used quite frequently, especially related to libraries that implement graphic user interfaces.
For years I thought a "foundation" was a GUI library that had a "main" or a "WinMain?" implementation in a helper class that helped to hide all of the horrible intricacies of creating Windows(tm) applications.
Finally, after a bit of education from some well written books and after being mentored by Dr. John, I finally understood what a framework is.
A framework is a collection of interfaces that define abstract components as well as some implementation that defines the interaction of the interfaces. In C++, the interfaces are all a collection of pure abstract classes.
