dlib C++ Library - API Wrappers

API Wrappers

These wrappers provide a portable object oriented interface for networking, multithreading, GUI development, and file browsing. Programs written using them can be compiled under POSIX or MS Windows platforms without changing the code.

[top]

# dir_nav

This is a set of objects that provide an easy and portable way to traverse a directory tree.
C++ Example Programs: dir_nav_ex.cpp
More Details...
#include <dlib/dir_nav.h>
Implementations:

> dir_nav_kernel_1: MS Windows implementation
> dir_nav_kernel_2: POSIX implementation

# Extensions to dir_nav

dir_nav_extensions
This is just some miscellaneous extensions to the dir_nav component.
More Details...
[top]

# gui_core

This is a set of objects and functions which provide a very basic framework for manipulating windows. It is intended to provide a portable interface which can be used to build a more complex windowing toolkit.
More Details...
#include <dlib/gui_core.h>
Implementations:

> gui_core_kernel_1: MS Windows implementation
> gui_core_kernel_2: X Windows implementation

[top]

# gui_widgets

This component is a collection of various windowing widgets such as buttons, labels, text boxes, and so on. It also includes the drawable interface, drawable_window, and font handling objects. dlib/gui_widgets/widgets_abstract.h defines all of the high level graphical widgets provided by this component that can appear in a drawable_window. To view the specifications for the other members of this component look at dlib/gui_widgets/fonts_abstract.h, dlib/gui_widgets/drawable_abstract.h, and dlib/gui_widgets/base_widgets_abstract.h.

This component isn't actually a wrapper on top of OS APIs. Rather, it is implemented on top of the gui_core component. I put it on this page just because I expect that people would look here when searching for the sort of functionality provided by this component.

## Primary widgets

C++ Example Programs: gui_api_ex.cpp, image_ex.cpp, 3d_point_cloud_ex.cpp, surf_ex.cpp, bayes_net_gui_ex.cpp
#include <dlib/gui_widgets.h>
[top]

# misc_api

This is just a collection of miscellaneous APIs that were small/simple enough not to warrant their own module.
More Details...
#include <dlib/misc_api.h>
Implementations:

> misc_api_kernel_1: MS Windows implementation
> misc_api_kernel_2: POSIX implementation

[top]

# sockets

This is a set of objects that provides an easy to use and object oriented interface for dealing with TCP networking. There are currently two implementations, one for UNIX and another for all versions of Windows after Windows95. Both provide the exact same interface so programs written with them can be recompiled on either platform without a problem.

You also may want to take note of the timeout object. It provides a mechanism which you can use to add a timeout to a network operation.

C++ Example Programs: iosockstream_ex.cpp, sockets_ex.cpp, sockstreambuf_ex.cpp, server_http_ex.cpp, server_iostream_ex.cpp
More Details...
#include <dlib/sockets.h>
Implementations:

> sockets_kernel_1: MS Windows implementation
> sockets_kernel_2: POSIX implementation

# Extensions to sockets

sockets_extensions
This is just some miscellaneous extensions to the socket api.
More Details...
[top]

# threads

This is a set of objects that provides an easy to use and object oriented interface for creating multi-threaded programs. There are currently two implementations, one for UNIX and another for any variant of MS Windows after Windows 95. Both provide the exact same interface so programs written with them can be recompiled on either platform without a problem.

You also probably want to take note of the pipe object. It provides an easy to use typesafe mechanism to send messages between threads.

C++ Example Programs: threads_ex.cpp, logger_ex_2.cpp, pipe_ex.cpp, multithreaded_object_ex.cpp, threaded_object_ex.cpp, thread_function_ex.cpp, thread_pool_ex.cpp
More Details...
#include <dlib/threads.h>
Implementations:

> threads_kernel_1: MS Windows implementation
> threads_kernel_2: POSIX implementation

# Extensions to threads

async
This function behaves just like std::async() except that instead of spawning a new thread to process each task it submits the task to a dlib::thread_pool. Therefore, dlib::async() is guaranteed to use a bounded number of threads unlike std::async(). This also means that calls to dlib::async() will block if there aren't any free threads in the thread pool.
More Details...
auto_mutex
This extension adds a mechanism to automatically lock and unlock a mutex. Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
C++ Example Programs: threads_ex.cpp More Details...
auto_mutex_readonly
This extension adds a mechanism to automatically perform a readonly lock and unlock of a read_write_mutex. Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
More Details...
auto_unlock
This extension adds a mechanism to automatically unlock a mutex. Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
More Details...
auto_unlock_readonly
This extension adds a mechanism to automatically remove a readonly unlock from a read_write_mutex. Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
More Details...
create_new_thread_extension
This extension adds some templated overloads to the create_new_thread() function. They allow you to create new threads using member functions from a class. Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
More Details...
default_thread_pool
This function returns a reference to a global thread_pool. If the DLIB_NUM_THREADS environment variable is set to an integer then the thread pool will contain DLIB_NUM_THREADS threads, otherwise it will contain std::thread::hardware_concurrency() threads.
More Details...
multithreaded_object
This object represents a multithreaded object. It is similar to the threaded_object except it allows you to have many threads in a single object rather than just one.
C++ Example Programs: multithreaded_object_ex.cpp, pipe_ex.cpp More Details...
parallel_for
This is a set of functions for executing the contents of a for loop in parallel. It is useful for taking advantage of multi-processor systems.
C++ Example Programs: parallel_for_ex.cpp More Details...
read_write_mutex
This extension adds a mutex object that can perform both normal "write locks" as well as "readonly locks". See the specification for details. Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
More Details...
rmutex
This extension adds a mutex object that can handle recursive calls to lock(). Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
More Details...
rsignaler
This extension adds a signaler object that can be used with the rmutex object. Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
More Details...
threaded_object
This extension represents a simple threaded object. It provides a convenient mechanism to create an object that contains a thread.
C++ Example Programs: threaded_object_ex.cpp More Details...
thread_function
This object represents a thread on a global C++ function. That is, it allows you to run a global function in its own thread.
C++ Example Programs: thread_function_ex.cpp More Details...
thread_pool

This object represents a fixed size group of threads which you can submit tasks to and then wait for those tasks to be completed. It also provides a future object that provides a container which allows you to safely pass objects into the tasks.

The implementation of this extension can be found here. It is implemented such that no memory allocations occur after the thread pool has been constructed so long as the user doesn't call any of the add_task_by_value() routines. The future object also doesn't perform any memory allocations or contain any system resources such as mutex objects.
C++ Example Programs: thread_pool_ex.cpp More Details...
thread_specific_data
This extension adds the ability to easily create thread specific data.
More Details...