Underlying Functions
Robust and stable underlying layer is very important for any c ++ framework. vol: the core is a new C ++ universal library based on the reference of the popular underlying libraries of multiple commercial game engines.
Class description
Vol: The core framework is a multi-platform C ++ common library that supports 32-bit (x86) and 64-bit (IA64 and x64) CPUs, it can be roughly divided into the following functions:
I. general implementation support:
- Container: [common. H & common. INL] variable array, two-way linked list, stack, queue and ing table, red/black tree (TBD)
- Encoding and encryption: [codec. H & codec. INL-reversible encoding and encryption]
[Crypto. H & crypto. INL-Irreversible encoding and encryption]
MD5, (Sha, AES, RC4, RC5, rc6, base64, and blowfish) (TBD)
- Exception base class: [exception. H & exception. INL]
- Handle base class: [Handle. H & handle. INL]
- Linear Algebra: (TBD)
- Dynamic Library Loading: [module. H & module. INL]
- Random algorithm: [Rand. H]
- Smart pointer: [refcount. H & refcount. INL]
- Run type information (rtti): [rtti. H & rtti. INL]
- Single-piece encapsulation: [singleton. H & singleton. INL]
- Serialization: [stream. H & stream. INL]
- Support for serialization of cache: [streambuf. H & streambuf. INL]
- File serialization support: [streamfile. H & streamfile. INL]
- Synchronous/asynchronous objects: [Sync. H & Sync. INL]
- Type features (character string operation encapsulation): [traits. H & traits. INL]
- String: [tstring. H & tstring. INL]
- UUID (universal unique identifier): [UUID. H & UUID. INL]
Ii. Common single-piece implementation:
- Hardware and platform information: [platform. H]
Parse the startup command line parameters to determine the debug information output level
Debug version enable CRT memory Application Tracking
Obtain CPU and memory information
Save Vol: core running status information
- Hash: [hash. H] hash implementation based on CRC algorithm
- Memory Manager: [mobject. H] memory application and release management, tracking memory usage
- Local Memory Management: [memaid. H] dynamic memory management at the local scope level,
You can apply for dynamic memory in a specific scope without releasing it,
Manage a large number of fixed-size cache for reuse at the same time
- Shared data table: [keyValue. H] stores data in the table by name for sharing
- File Path Management: [filepath. H] file and directory creation, copying, moving, search operations, and saving PATH variables
- Thread Pool: [thread. H] thread management and thread task Maintenance
- Event Management: [event. H] asynchronous event management
- Object Manager: [object. H] object Object Management
Framework Description
Example
Vol: the current version of core is a 32-bit (x86) Windows dynamic link library version. Next we will use an example to learn how to use the underlying library step by step.
Hello world example
Just like learning computer programming, we start from "Hello world !" Start.
1. create a C ++ Win32 project. You can use the console program or standard program. After the project is created, configure the project parameters and copy the three directories in SVN to the directory saved in the solution file.
Click Properties of testcore0 to enter the Properties dialog box.
- Debugging option-devlevel: XXXX [the value is composed of debugging information output in def. H]
Enum
Log_level
{
Logrochelle trace = 0x00000020,
// 32-memory application/release information, and intermediate state information of threads and events
Logl_debug = 0x00000010,
// 16-intermediate debugging status information
Logl_info = 0x00000008,
// 8-standard information
Logl_dump = 0x00000004,
// 4-dump Information
Logl_warn = 0x00000002,
// 2-warnning Information
Logl_error = 0x00000001,
// 1-error information
Logl_devmode = 0x00001000,
// Outdebugstring
};
Check the debugging output in the VC output window or dbgview, and add the value 4096. In the figure, "4159" indicates that all debugging information is output, and "4127" indicates that all other information except trace information is output.
- Working directory: $ (targetdir) [indicates the directory where the final execution file is compiled]
When 4096 is not added as the log file output, the default Log Path is the directory where the execution file is located, rather than the directory where the default project file vcproj of testcore0 is located.
- Change the configuration to all configurations, and then add the following two items in the "C ++ General à" dialog box that contains the directory vertex:
And .. \ include [relative path of the directory where the project file vcproj of testcore0 is located]
- The following two items are added in the dialog box that appears when you click "general"> "add database directory:
And .. \ Lib [relative path of the directory where the project file vcproj of testcore0 is located]
- Enter a dependency for the connector. [You do not need to enter the dependency. Use the command line to include the dependency in the Code.]
Debug: cored. Lib
Release: core. Lib
2. The project uses Vol: core, which must contain the header file, which is in stdafx. H of the project.
// Stdafx. h:
Standard System Inclusion files,
//
Or frequently used but rarely changed
//
Project-specific inclusion files
//
# Pragma
Once
# Include
"Inc. H"
//
Replace the header file with the class he needs
//
If the above link library configuration does not contain dependencies, you can use the following command line to add
# Ifdef _ debug
# Pragma comment (Lib,
"Cored. lib ")
# Else
# Pragma comment (Lib, "core. lib ")
# Endif
3. Add a debug information output statement to the main of the source file.
[The debugging information is automatically added with the carriage return line break upon each call. Except for special requirements, line breaks are not required for the output information.]
// Testcore. cpp:
Define the entry point of the console application.
# Include
"Stdafx. H"
Using
Namespacevol; // Vol: Core belongs to the vol namespace
Int _ tmain (intargc, _ tchar * argv [])
{
Dev_info (Tf ("Hello world! "));
// Output Hello world in the debugging information !,
Return 0;
}
4. Run the example Program
Directly debug and run in VC, the following error will occur:
If the DLL file is missing, copy the core. dll and cored. DLL files in the dll Directory to the compiled directory. [the solution file is the DEBUG directory of the actual directory by default]
You can run the program below. Because 4096 is added before the debugging information output, the output is in the VC output window.
[Debug] -- >>> static platform build [Jul 8 2012, 16:53:37] Debug Memory Leak trace ready <---
[Debug] load cored. dll --- dll_process_attach
[Info] * Static CRC table init okay
[Info] * Memory Manager Singleton [520] init okay
[Info] Hello world!
[Dump] * cmemmanager Singleton leak report [total leak chunk 0]
[Dump] * Report chunk 0, Block 0
[Dump] * --- cmemmanager Singleton stats report ---
[Dump] | cur used size: 0.0 [MB]
[Dump] | max used size: 0.0 [MB]
[Dump] | cur cache size: 0.0 [MB]
[Dump] | max cache size: 0.0 [MB]
[Dump] | Total useds time: 0.000 [s]
[Dump] | alloc used time: 0.000 [s]
[Dump] | realloc used time: 0.000 [s]
[Dump] | free used time: 0.000 [s]
[Info] * --- Memory Manager Singleton exit okay ---
[Dump] * --- CRC table stats report ---
[Dump] | used count: 0
[Dump] | used time: 0.000 [s]
[Info] * --- static CRC table exit okay ---
[Debug] unload cored. dll --- dll_process_detach
[Debug] -- >>> static platform debug Memory Leak trace exit <---
This is the output result of the Vol: Core debugging information. You can also click the compiled execution program. The default output is a log file. Let's compile a release version to check the output.
Double-click the execution program of the release version. By default, the log file is generated. [The release version has no trace or debug output information. The two types of output information are only available in the debug version.]
To control output information, you can create a shortcut and add parameters.
In this way, run the shortcut directly. According to the running parameters, the debugging information is output by outdebugstring. You can use dbgview to monitor the output.