For the most part, people think of DLLs as passive blobs of data which have no proactive component at all. It is only a package of functionality which is driven by the using application (or other DLL.) However, in many ways, this is not true or at least does not have to be true. In CIDLib, an object represents each linkable module. There is only one instance of the 'facility object' of each facility, and it represents the overall DLL itself. In a way, it is the the facility's representative to you.
All facility objects are of the type TCIDFac or some derivative of it. TCIDFac provides the basic functionality that all facilities must provide, such as the ability to load resources and to do logging. Logging is also very related to facilities, as will be explained below. In many cases, an EXE module will just create an object of type TCIDFac. But most DLLs, unless they are very simple, will want to add some small amount of functionality of its own. For instance, the facility object is where all global data of the facility is at, as well as any functionality that applies to the facility as a whole.
The CIDLib.Dll facility is a good example. It derives a TFacCIDLib class from the basic TCIDFac class. The TFacCIDLib class adds in support for getting and setting a lot of very fundamental system values, such as the OS version, CPU count, command line parms, etc... In the main header for CIDLib, CIDLib.Hpp, it will export its one instance of this class to the outside world. These instances are always named after the facility, so the CIDLib facility object is called facCIDLib.
As a matter of fact, a very simple Exe program which has no need to log its own messages or load any resources attached to it, can get away without having a facility object. In general though, its pretty much always done.
All files are mixed case and non-trivial. I absolutely will not use a tool that does not maintain the case of the files as I created them. You will notice that the CIDLib release has the cleanest, neatest directories you've ever seen. I hold this as a matter of craftmanship, and I hope that you will appreciate the effort involved in even such a small thing. The file names are non-trivial so that I can use a single, common output directory for all files. All files are unique because they are all based upon the facility name.
Here is a listing of all of the files that go into a facility, and what their content is.
Def File
CIDLib just uses a very simple, and almost always exactly the same, Def file. Here is the one from the CIDRay facility:Dependency FileLIBRARY CIDRay INITINSTANCE TERMINSTANCE DESCRIPTION 'CIDLib C++ Ray Tracing Kernel' PROTMODE DATA MULTIPLE NONSHARED CODE LOADONCALLIt sets the name of the library, and insures that it uses per-instance term/init. Data is made multiple and nonshared so that each instance of the DLL gets its own copies of all data segments.This file is generated automatically usually, via some sort of dependency analyzer. CIDLib comes with a dependency analyzer that is used internally for its own development and which can be used for your own. If you use the CIDLib development shell, it understands how to use the dependency analyzer in a very smart way. This file should be useful for most make type programs since the format is very simple.Internal HeaderMany times a DLL will need to have a means of sharing some functionality only internally with its other modules within the facility. For more complex ones, this is almost always the case. This stuff cannot (actually should not) be put into the public headers, partly because they are implementation details that could change and because (during internal development) they would cause bogus rebuilds of anything that used those headers.Main ModuleAll CIDLib DLLs will use an internal header. It will import the DLL's public header also, so that all of the DLL's internal modules just import the one internal header to get access to both internal and public functionality.
The main Cpp and Hpp file of a DLL are generally kind of special, and definitely are in the CIDLib scheme. They are also important in EXEs, but to a lesser degree. In a DLL, the main header is the one file that clients of the DLL should have to ever import. It will sub-include any of its other headers, using the standard CIDLib scheme for conditional inclusion. The main Cpp file contains the DLL initialization code, which the operating system calls to allow the DLL to initialize its data within the context of a new process that is about to use it. It will also often contain some primal internal functionality that is core to the services provided by that DLL.The Type ModuleFor EXEs, the main module usually holds the startup code, where the program begins executing. It will often also be home to most of the global data of the program.
The type module is very special in the CIDLib architecture. EXEs will not generally have one, but all of the CIDLib DLLs do. The Hpp file will contains a structure that acts as a pseudo name space for all non-class constants, types, prototypes, etc... that are not private to some class. This is contrary to the general C++ scheme in which such things are always distributed amongst one or another class. However, I've found that (particuarly for fundamental values) there are many uses for them not forseen by the designer of the class. This requires the user to import the entire class definition (and all of the things it depends upon) often just to get one stinkin enum or constant. CIDLib avoids this by putting them in a separate namespace.Of course, some such types or constants really are specific to a class and are nested within the class in the usual way. In such cases, they are often private to the class or protected for use just within that class' family tree, but that is not always the case.