Poco project
Overview
The POCO C++ Libraries are a collection of open source C++ class libraries that simplify and accelerate the development of network-centric, portable applications in C++. The libraries integrate perfectly with the C++ Standard Library and fill many of the functional gaps left open by it. Their modular and efficient design and implementation makes the POCO C++ Libraries extremely well suited for embedded development, an area where the C++ programming language is becoming increasingly popular, due to its suitability for both low-level (device I/O, interrupt handlers, etc.) and high-level object-oriented development. Of course, POCO is also ready for enterprise-level challenges.
POCO consists of four core libraries, and a number of add-on libraries. The core libraries are Foundation, XML, Util and Net.
Two of the add-on libraries are NetSSL, providing SSL support for the network classes in the Net library, and Data, a library for uniformly accessing different SQL databases.
POCO aims to be for network-centric, cross-platform C++ software development what Apple's Cocoa is for Mac development, or Ruby on Rails is for Web development — a powerful, yet easy and fun to use platform to build your applications upon.
POCO is built strictly using standard ANSI/ISO C++, including the standard library. The contributors attempt to find a good balance between using advanced C++ features and keeping the classes comprehensible and the code clean, consistent and easy to maintain.
The Foundation Library
The Foundation library makes up the heart of POCO. It contains the underlying platform abstraction layer, as well as frequently used utility classes and functions. The Foundation library contains types for fixed-size integers, functions for converting integers between byte orders, an Poco::Any class (based on boost::Any), utilities for error handling and debugging, including various exception classes and support for assertions. Also available are a number of classes for memory management, including reference counting based smart pointers, as well as classes for buffer management and memory pools. For string handling, POCO contains a number of functions that among other things, trim strings, perform case insensitive comparisons and case conversions. Basic support for Unicode text is also available in the form of classes that convert text between different character encodings, including UTF-8 and UTF-16. Support for formatting and parsing numbers is there, including a typesafe variant of sprintf. Regular expressions based on the well-known PCRE library (http://www.pcre.org) are provided as well.
POCO gives you classes for handling dates and times in various variants. For accessing the file system, POCO has Poco::File and Poco::Path classes, as well as a Poco::DirectoryIterator class. In many applications, some parts of the application need to tell other parts that something has happened. In POCO, Poco::NotificationCenter, Poco::NotificationQueue and events (similar to C# events) make this easy. The following example shows how POCO events can be used. In this example, class Source has a public event named theEvent, having an argument of type int. Subscribers can subscribe by calling operator += and unsubscribe by calling operator -=, passing a pointer to an object and a pointer to a member function. The event can be fired by calling operator (), as its done in Source::fireEvent().
#include "Poco/BasicEvent.h"
#include "Poco/Delegate.h"
#include <iostream>
using Poco::BasicEvent;
using Poco::delegate;
class Source
{
public:
BasicEvent<int> theEvent;
void fireEvent(int n)
{
theEvent(this, n);
}
};
class Target
{
public:
void onEvent(const void* pSender, int& arg)
{
std::cout << "onEvent: " << arg << std::endl;
}
};
int main(int argc, char** argv)
{
Source source;
Target target;
source.theEvent += delegate(&target, &Target::onEvent);
source.fireEvent(42);
source.theEvent -= delegate(&target, &Target::onEvent);
return 0;
}
The stream classes available in POCO have already been mentioned. These are augmented by Poco::BinaryReader and Poco::BinaryWriter for writing binary data to streams, automatically and transparently handling byte order issues.
In complex multithreaded applications, the only way to find problems or bugs is by writing extensive logging information. POCO provides a powerful and extensible logging framework that supports filtering, routing to different channels, and formatting of log messages. Log messages can be written to the console, a file, the Windows Event Log, the Unix syslog daemon, or to the network. If the channels provided by POCO are not sufficient, it is easy to extend the logging framework with new classes.
For loading (and unloading) shared libraries at runtime, POCO has a low-level Poco::SharedLibrary class. Based on it is the Poco::ClassLoader class template and supporting framework, allowing dynamic loading and unloading of C++ classes at runtime, similar to what's available to Java and .NET developers. The class loader framework also makes it a breeze to implement plug-in support for applications in a platform-independent way.
Finally, POCO Foundation contains multithreading abstractions at different levels. Starting with a Poco::Thread class and the usual synchronization primitives (Poco::Mutex, Poco::ScopedLock, Poco::Event, Poco::Semaphore, Poco::RWLock), a Poco::ThreadPool class and support for thread-local storage, also high level abstractions like active objects are available. Simply speaking, an active object is an object that has methods executing in their own thread. This makes asynchronous member function calls possible — call a member function, while the function executes, do a bunch of other things, and, eventually, obtain the function's return value. The following example shows how this is done in POCO. The ActiveAdder class in defines an active method add(), implemented by the addImpl() member function. Invoking the active method in main() yields an Poco::ActiveResult (also known as a future), that eventually receives the function's return value.
Reference
https://docs.pocoproject.org/current/00100-GuidedTour.html