Coder Social home page Coder Social logo

nowisesys / citrus-application Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 32 KB

Application executor and monitor for C++

License: Other

Makefile 6.52% Shell 0.37% M4 8.45% C++ 84.65%
citrus application-launcher application-monitoring library cxx11

citrus-application's Introduction

Citrus C++

Application executor and monitor for C++ (citrus-application)

Provides an OOP approach for running applications. The application core is implemented as an derived class providing protected methods to handle lifetime events. An optional monitor can be applied on the running process.

Command line parsing is handled premature by the base class so that the programmer can focus on the essential part, like implementing the business logic instead. An minimal implementation needs to at least define the abstract Run() method.

Example

#include <iostream>
#include <citrus/application.hpp>

class MyApplication : public Application 
{
        public:
                MyApplication(int argc, const char **argv)
                        : Application(argc, argv)
                {}

        protected:
                void Run(const Options & options) override 
                {
                        // Application code goes here
                }

                void Usage() const override 
                {
                        // Show usage information
                }

                void Version() const override 
                {
                        // Show application version
                }
};

int main(int argc, const char **argv)
{
        MyApplication app(argc, argv);
        app.Start();

        return 0;
}

Lifetime methods

The base class provides protected lifetime methods that can be overridden to alter default behavior, for example trap standard exceptions.

class MyApplication : public Application
{
    protected:
                ...

        void OnInitialize() override
        {
                // Allocate resources
        }

        void OnCleanup() override
        {
                // Release resources
        }

        void OnException(const std::exception & exception)
        {
                // Suggested: log, wait and restart application
        }
};

Please examine the header application.hpp for all virtual methods who's behavior can be overridden.

Requirements

Command line parsing is handled by citrus-options and should be installed as a pre-requisite.

Building

A standard installation into /usr/local:

bash$> ./autogen.sh
bash$> ./configure
bash$> make && make install

Pass --prefix=path to configure or use DESTDIR for make install to install in non-standard locations.

Getting started

See the examples directory for complete code ready to be run.

License

This library is released under LGPL-3.0 and can be linked and used with commercial applications.

Bug report & suggestions

Please see the AUTHORS file for contact information. Feel free to submit bug reports, patches and suggestions.

citrus-application's People

Contributors

nowisesys avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.