$Header: /cvsroot/libjmmcg/libjmmcg/docs/index.html,v 1.15 2008/08/09 00:41:02 jmmcg Exp $
JMMcG's Core C++ Libraries.
Introduction.
These files are a header-only implementation, no object files need be linked.
In core there are files that implement a number of useful features:
-
Trace output. Use the macro "JMMCG_TRACE(...)" with a string argument to output to "std::cerr" (or the debug window under MSDevStudio) the file and line (amongst other thigs) prefixed string argument. A handy "got here!" dump. "JMMCG_TRACE(...)" compiles to nothing if "DEBUG" is not "#define"d.
-
Exceptions that have the file, line, revision, function and argument details. Also puts out a "JMMCG_TRACE" message on construction and copy, so you can see from where an exception was throw. Caught exceptions are useless for debugging. This makes exceptions much more powerful. These are also wide/narrow-character compliant. Now all I need to do is get it into the STL...
-
A "#define" for "dynamic_cast< ... & >(...)". This throws "std::bad_alloc". From where... Nobody knows. Useless, unless you use the "JMMCG_CHK_DYN_CAST" macro instead. It converts the "std::bad_alloc" into a "jmmcg::exception" that therefore includes location information. Much more useful at run-time!
-
CRT exceptions that include the CRT errno in them.
-
A few string utilities, convert anything to a string and extract anything from a string if "operator<<(...)" and "operator>>(...)" are defined.
-
Some macros to wrap using "wchar_t" and "char" so that you can ignore them, and just "#define" "_JMMCG_WIDE_CHARS" for getting "wchar_t" otherwise you get "char".
-
Logging to a log file, with exceptions thrown if the logging failed. Log output includes internationalized date & time, user, process & pid plus the message. The level of logging can be set by the user in the log object, so logging can be filtered.
-
Simple command line processing to set program data. This includes by default log-level setting, help & version. Arbitrary paramters may be supported with help output and simple parsing.
-
XML-format configuration file processing. This will make use of an XDR schema to validate the configuration file.
-
A function to get the local time & date in the current locale as a string.
-
A meter class that allows you to obtain the arithmetic mean of a value and the average deviation of that mean.
-
Functions for convering narrow strings to wide strings and vica-versa.
-
A class for creating peano curves.
Experimental Code.
In experimental there are files that I have been occasionally mucking with from my past.
Stuff that actually worked & I use/used:
NT-based:
There are files that are from my NT-based developer days. It contains some quite snazzy stuff, amongst other things:
-
Thread-wrapping class - this is mature and worked. It wraps all the aspects of creating and terminating threads gracefully in the Win32 platform. Derive from this class, implement your worker code, and you can even bung it into an "std::vector<...>" to create a pool of them! (But note that destruction of each thread is blocking, so will block the "std::vector<...>" destructor, i.e. each thread is not destroyed in parallel.)
-
Win32 system-registry key wrapping.
-
Win32 NT Event Log wrapping.
-
Asserting to the Win32 NT Event Log if "DEBUG" is defined, c.f. "assert(...)", but with an NT-Service you've no U.I. to debug them, so this was well handy, as you can view the NT Event-Log of one machine from another, if you are remotely debugging the service you are creating.
-
Various wrappers for Win32 Security objects, most importantly an "Everyone" permission object for setting up the permissions on named mutexes for intra-process use (otherwise you'll get permissions problems on Win32).
-
Various C++ class-wrappers for Win32 events, mutexes & critical sections, for both anonymous & named ones (for intra-process use).
-
Functions for loading and saving BMPs.
-
A very simple wrapper class and helper functions for MSXML4, which includes converting things to and from XML.
-
A very simple wrapper class and helper functions for COM.
-
Functions for getting GUIDs, checking if you're running on NT, converting Windows error numbers to strings, etc, etc.
-
An exception class (that derives from the core exception class) that can automatically add the "GetLastError()" number and string to it.
-
Network stuff:
-
A class for connecting to a remote machine's Service Control Manager.
-
A class for connecting to a remote machine's Task Scheduler.
-
A class for creating network file shares (on both local & remote machines).
-
A C++ cache-manager heirarchy with various levels of "intelligence" - basically to wrap a map of key to object, but dynamically manage populating the map. The most sophisticated version used a separate thread to populate the map on demand, but flushed it out using an LRU algorithm, the size of the map being dynamically manipulated according to a simple local-optimisation algorithm. The heuristic for the local opimisation algorithm was based on minimising look-up time with a contrain of a maximum number of keys.
-
Various other bits & bobs like local system time, a class for loading and freeing DLLs, blah blah.
Stuff that I never finished, so never compiled, or is buggy:
These files are in here.
-
A real implementation of "std::allocator < ... > " (which is not so easy to use) for typed shared memory, see SharedMemory.hpp. Yes - we all read that you could use it for such, but where were the sodding examples, hmmmm? Not one single snippet of even shite code. My idea was to wrap memory-mapped files with an "std::allocator < ... > " compatable class. Yes - memory persistence because they are FILES. Wooo! :) Unfortunately "std::allocator < ... > " is actually useless for the job everyone seems to think it can do. Indeed it is shite as a class and should really be removed or replaced in the STL, and all those "shared memory" quotes should be deleted too. If you can figure out the how this code is supposed to work, I'll be impressed! Anyway, I got as far as implementing a typed shared-memory wrapper that was nearly "std::allocator < ... > " compatible (using static member-templates as initialisation parameters, you see I want more than one shared memory heap - so I need to identify which one I'm using, but "std::allocator < ... > " uses a default constructor. So no parameter can be easily passed to identify which heap you want to use use. I also got lost in implementing a memory manager for the heaps I was making. See the nirvana? Multiple heaps, so you allocate objects X on heap x, objects Y on heap y and objects a,b & c on heap Z. Wooo.... Funky! Also not that by wrapping the memory manager with a DCOM wrapper, you could remote it to another machine. So your heap is actually on another machine! WOW! 8-0 Ok: What's the point apart from making "new" even slower? Who said it had to be one ONE other machine? How about spreading your heap across multiple machines? Hmmmm? Template the "pointer" type with an arbitrary-sized integer and you have "unlimited" address space. How about allocating 2*10900 TB on NT? No problems, as long as you have enough machines! WOW! Why would you want to do this? TUT! Call yourself a geek! BECAUSE YOU CAN!
-
The real reason I started mucking around with this shared-memory junk is I wanted to have a C++ wrapper to the NT Performance Monitor, PerfMon, counters. But now-a-days I use the ATL PerfMon addin instead. It's easy to use and works.
Documentation.
Browseable HTML is here: HTML docs. Or as a single PDF file.
Example Code.
This is included in the examples sub-directory.
Building.
Clearly this would be included as part of another project. But it does have certain requirements (on *nix & NT):
-
libstdc++ (for *nix, the STL as installed by MSDevStudio, or equivalent for Win*): The C++ Standard Library, usually installed as part of your G++ installation.
-
libboost (for parts of the *nix stuff, the NT-bits don't actually use Boost): The Boost library, v1.29 or greater.
-
libxml2 (for parts of the *nix stuff, the NT-bits use MSXML4): The 'C' XML library, v2.5.1 or greater.
-
libxml++ (for parts of the *nix stuff, the NT-bits use MSXML4): The 'C++' wrapper to the above, v0.21 or greater. See "http://sourceforge.net/projects/libxmlplusplus".) Ensure that if you use the Sourceforge download of libxml++ that you modify your "/etc/ld.so.conf" file to include "/usr/local/lib" and run "ldconfig" to update the dynamic-linker path-cache correctly.
-
Others I haven't thought of yet.
Build platforms tested:
License & Warranty.
This library is released under the LGPL, with absolutely no warranty, express or implied. Please see the files "COPYING" and "WARRANTY" in the release distribution for more details.
More details.
Credits.
This code was developed by J.M.McGuiness.