Download the latest version: 0.9.2
Omni is a cross platform, object oriented library written in C++ and designed to give the developer a functional and reusable tool set.
With its easy to understand interfaces, recognizable paradigms like managed thread objects, delegates and events, and its permissive free license, Omni enables you to get clean and stable C++ code to a wider market faster while lowering future code maintenance costs.
Check out the examples or classes section for more on working with the library or visit the getting started page to get up and running with Omni; for more information about which platforms are currently supported, visit the cross platform section.
Please note: the library (and documentation) are in beta and are publicly available so anyone interested may follow its progress until the release of 1.0 (version 1.0 will be feature complete and be fully documented).
Thank you for your interest in the Omni library and stay tuned for more.
A Quick Example:
The following is a simple demonstration of Omni to give an example of some of the feature sets the library can provide. Like most examples this is not intended to demonstrate a "live" example of any real-world code, more of how Omni can be utilized and a demonstration of a few of the classes.
For more, you can visit the examples page or the
class index to browse the library.
Omni is a cross platform, object oriented library written in C++ and designed to give the developer a functional and reusable tool set.
With its easy to understand interfaces, recognizable paradigms like managed thread objects, delegates and events, and its permissive free license, Omni enables you to get clean and stable C++ code to a wider market faster while lowering future code maintenance costs.
Check out the examples or classes section for more on working with the library or visit the getting started page to get up and running with Omni; for more information about which platforms are currently supported, visit the cross platform section.
Please note: the library (and documentation) are in beta and are publicly available so anyone interested may follow its progress until the release of 1.0 (version 1.0 will be feature complete and be fully documented).
Thank you for your interest in the Omni library and stay tuned for more.
A Quick Example:
The following is a simple demonstration of Omni to give an example of some of the feature sets the library can provide. Like most examples this is not intended to demonstrate a "live" example of any real-world code, more of how Omni can be utilized and a demonstration of a few of the classes.
#include <omnilib> typedef std::vector<omni::net::endpoint_descriptor*> endpoint_list; class server { public: server() : m_clients(), m_sock(omni::net::address_family::INET, omni::net::socket_type::STREAM, omni::net::protocol_type::TCP), m_mtx(), m_run(false) { if (this->m_sock.bind(12345) == omni::net::socket_error::SUCCESS) { this->m_sock.listen(); } } ~server() { this->_stop(); } bool is_running() const { omni::sync::scoped_basic_lock lock(&this->m_mtx); return this->m_run; } void run() { this->m_mtx.lock(); if (this->m_sock.is_listening()) { this->m_run = true; } this->m_mtx.unlock(); while (this->is_running()) { omni::net::endpoint_descriptor* client = new omni::net::endpoint_descriptor(); if (this->m_sock.accept(*client) == omni::net::socket_error::SUCCESS) { this->m_clients.push_back(client); } } } void signal(int sig) { omni::sync::scoped_basic_lock lock(&this->m_mtx); uint32_t sent = 0; char buff[] = {'E','N','D','\0'}; std_foreach(endpoint_list, client, this->m_clients) { (*client)->send(buff, sent); } this->m_run = false; } operator bool() { omni::sync::scoped_basic_lock lock(&this->m_mtx); return this->m_sock.is_listening(); } private: endpoint_list m_clients; omni::net::socket m_sock; mutable omni::sync::basic_lock m_mtx; volatile bool m_run; void _stop() { omni::sync::scoped_basic_lock lock(&this->m_mtx); std_foreach(endpoint_list, client, this->m_clients) { (*client)->close(); delete (*client); } this->m_sock.disconnect(false); // shutdown and don't reuse socket } }; int main(int argc, const char* argv[]) { server srv; if (srv) { omni::application::run_type rt = omni::application::run_type::EXIT_WITH_WORK_THREAD | omni::application::run_type::KILL_WORKER_ON_SIGNAL; omni::application::signal_handler::attach(omni::application::signal_handler::callback::bind<server, &server::signal>(&srv)); return omni::application::run(argc, argv, omni::sync::bind<server, &server::run>(&srv), rt); } return -1; }