| cpgf | documentation | download | change log | support |
cpgf library -- a free C++ open source library for reflection, script binding, callbacks
cpgf is a free, open source and cross platform C++ library.cpgf is composed by several independent components:
- cpgf reflection -- a library to add reflection feature to C++.
- cpgf script binding -- a script binding engine to bind Lua and Google V8 Javascript to C++. It's based on the reflection library.
- cpgf callback -- a callback library to implement signal/slot or callback in C++. It's the primary library for other libraries.
- cpgf meta data collection -- a library with built-in meta data support. Now there are meta data for C++ STL, OpenGL, OpenGLU, and OpenGLUT.
cpgf provides a very easy to use callback system, which is common used in C# and script languages.
cpgf provides a powerful reflection and meta data system. Ever envy the reflection system in C# and Java? now we have it in C++!
cpgf makes binding Lua and Google V8 to C++ a piece of cake! The script binding engine uses the reflection system extensively.
Want to use OpenGL in Lua and Javascrit? It can't be easier using cpgf.
Vesion 1.2.5 is released on Feb.5, 2012.
Key features
- Provide easy to use class and function based library.
- Also provide interface based, Windows COM style, binary compatible API. It's easy to put meta data in a dynamic library and use the meta data from within another library.
- Written in (almost) standard and portable C++. It can be compiled in VC 2008, GCC 3.4.2, Intel Composer XE 12.1.2 and C++ Builder 2010, on Windows, Linux, and Mac.
- Extensively, but not abuse, using template programming.
- No need external preprocessor or code generation tools. Just coding and enjoy. Easy to setup, easy to integrate with your project.
- Free and open source.
Quick facts of reflection library
- As powerful as the reflection system in Java and C#.
- Reflect global/member functions, global/member fields (variable), global/member properties (fields with getter/setter), constructors, classes, enumerators, and annotations.
- Real runtime reflection. No compile time template parameters are needed when using the reflection.
- No external preprocessor required, no ugly macros. Only using C++ templates, classes, and functions.
- Support multiple inheritance.
- Support default parameters for constructor, method, and operators.
- For more information, please read cpgf reflection related documentation.
Quick facts of script binding library
- Very easy and simple to use. Any reflected meta data can be bound to scripts.
- Bind C++ classes, enumerators, functions, variables and operators to Lua and Google V8 Javascript.
- Invoke Lua and V8 Javascript functions from C++.
- Pass function written in script to C++ and used by C++.
- Get and set Lua and V8 Javascript variables from C++.
- Transfer arbitrary binary data between C++ and script.
- Pass arbitrary script function and object to C++.
- For more information, please read cpgf script binding related documentation.
Download cpgf library
Download the libraryDocumentations
Read the documentationsLicense
Apache License, Version 2.0Library version
1.2.5Change log
Change logAuthor and owner
Wang Qi, in Beijing, ChinaWebsite: http://www.kbasm.com/
Compatibility -- Tested compilers and platforms
Support GCC 3.4.2 and up, MS VC 2008 and up, C++ Builder 2010 and up, XCode and Intel C++ Compiler.Read this document for more information
Required third party library -- None for the primary libraries
Doesn't require C++0X, TR1 or C++11 features.Doesn't require Boost library.
For Lua binding, Lua library is required.
For Google V8 Javascript binding, V8 library is required.
If you want to run the unit test, UnitTest++ is required. But usually you don't need to do that.
Learning the library
Though there are some documentations on this website, they are far from good.They are incomplete, and not quite native reading.
The fastest way to get start with the library is to read the sample code in the folder "samples".
The sample code was originally written for test purpose, so they are not as easy to read as you expect. But they covers most features so it's a good kick off.
If you want to read more sample code, read the code in the folder "test".
They are for unit test. They are much more difficult to read and they use a lot of macros.
However, they cover much more functions than the sample code.
How is the library tested
Several measures are adopted to test the library.Unit test -- hundreds of unit tests were written and ran. More unit tests are being added for existing code and new code.
Valgrind -- valgrind is used to check memory leaks and other memory problems (wild pointer, double free, etc).
Code coverage -- GNU gcov is used to check the code coverage in unit tests. The ultimate goal is to cover all API functions and 80% implementation code. Though we didn't achieve the goal yet, we are closing to it day by day.
Contribute to the library
If you like the library and want to contribute to it, here are some most desired work to do1, Use the library in your real project. That will help the library much. A library is nothing without real projects using it.
2, Help with the documentation. I'm not a native English speaker, and I also don't enjoy writing documentation.
3, Test the library on more compilers and platforms, especially on 64 bit platforms and compilers.
What does cpgf mean?
The original cpgf means Cross Platform Game Framework.It was intended to be game framework that can work on PC and smart phone.
But later I decided to add more fun but non-game features to the library.
So now the library is neither for game nor a framework.
It's a cross platform C++ library.