Table of Contents
This chapter provides a step by step tutorial, that will show you how to create a new library containing a simple managed class. The complete sources of this example are stored in src/example/server_lib. They are also listed in Appendix F, Example Listings.
We will show how to create a new library that will be built using the Massiv build tool mkgen.pl. Then we will create a simple “hello world”-like example. For educational puposes it will be split into two managed classes - an interface and an implementation. Both IDL description (see Chapter 9, Introduction to IDL) and C++ implementation (see Chapter 4, Managed Objects and other chapters) of the classes will shown.
You may also want to read Section D.1, “Massiv Build Tools”. It contains a description of the build process in general, and a reference guide for the tools used to build a library or an application.
The example is split into an interface and an implementation for simple reasons: to show an example of class inheritance, attribute inheritance, description of virtual methods and other features. However, it may be useful to provide forward compatibility of the library too. If the implementation of the Hello class changed drastically, the Massiv Core would not be able to read archives containing an old version of the class. The Massiv Core does not support any form of class versioning directly. So instead of incompatible changes to existing classes, you should implement brand new classes that implement the same (and stable) interface (ShinHello, followed by HelloNisei and ShinHelloNiseiZ in the future, for example). Then you can either write a special code that converts old object versions to new ones, or just leave the old objects there if their old behavior is not harmful.
![]() | Note |
---|---|
The sources in the src/example/server_lib directory contain special comments that are used to automatically generate example copies in this document. You should ignore them. Also the line numbers in examples in this document are not the same as line numbers in the sources: the special comments as well as the first part with copyright and license information are not included in the examples. |
![]() | Note |
---|---|
This relatively simple tutorial does not demonstrate all features of the Core. The features not used in this example include complex property data structures, usage of pointers, replication, migration and replication groups, usage or implementation of special objects such as node objects and account objects, heavy use of RPC and more. You will have to check the sources of the Massiv Demo for more complex examples. |