Event driven console application

This is a discussion on Event driven console application within the C++ Programming forums, part of the General Programming Boards category; Has anyone come across a relatively simple event management class that can be used in a console application? Here is ...

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    5

    Event driven console application

    Has anyone come across a relatively simple event management class that can be used in a console application?

    Here is what I want to do:

    (1) The main function would wait for event and dispatch the actions based on event type:

    Code:
    main()
    {
      while (event) {
        do something 
      }
    }
    (2) The events would be triggered by various functions implemented in the application, eg.

    Code:
    function1() 
    {
      trigger event1
    }
    
    callback1() 
    {
      trigger event2
    }
    Typical scenario that the app will be running is something like this:

    generate event (read stdin) -> do something that returns callback -> callback triggers next event (eg. next line from stdin) -> do something that returns another callback -> ...

    This is supposed to be a multi-platform app so I would like to keep it close to standard C++

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    The nearest you're going to get to multi-platform is using ncurses on your POSIX hosts, and pdcurses on Win32
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,659
    For something more generic, there's boost::signals2.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simple snmp console application.
    By csteinsv in forum C++ Programming
    Replies: 0
    Last Post: 06-01-2009, 05:03 PM
  2. Replies: 7
    Last Post: 01-14-2008, 09:25 AM
  3. icon in win32 console application
    By osal in forum Windows Programming
    Replies: 3
    Last Post: 06-30-2004, 02:13 PM
  4. Console Application
    By Mont_Blanc in forum C++ Programming
    Replies: 3
    Last Post: 04-17-2004, 03:07 AM
  5. Move cursor in console application
    By alfa in forum C# Programming
    Replies: 2
    Last Post: 02-09-2003, 01:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21