Skip to content

mipalgu/gusimplewhiteboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gusimplewhiteboard

A simple POSIX whiteboard library.

Online Documentation

Prerequisites

You need a posix system a C/C++ compiler, cmake, and a build system supported by cmake, such as Ninja or gmake. You also need to install the following pre-requisite packages. Follow the links below for instructions:

Building and Installation

To build, you simply create a build directory (e.g. build.ninja) using cmake, then use your build system to build and install. Here is an example using Ninja:

mkdir ../build.ninja
cd ../build.ninja
cmake -G Ninja ../gusimplewhiteboard
ninja
ninja install

If you require root permissions, run ninja install as root, e.g. by using sudo:

sudo ninja install

Examples

C++

#include <guwhiteboardtypelist_generated.h>

int main()
{
    using namespace guWhiteboard;

    Print_t print;          // slot definition
    print("Hello, world!"); // post a message

    return 0;
}

C

#include <string.h>
#include <stdio.h>
#include <guwhiteboardtypelist_c_generated.h>

int main(int argc, char **argv)
{
    gu_simple_whiteboard_descriptor *wbd = get_local_singleton_whiteboard();
    gu_simple_whiteboard *wb = wbd->wb;
    wb_types print = kwb_Print_v;   /* slot for the 'print' message */

    /* Read the current whiteboard message */
    gu_simple_message *msg = gsw_current_message(wb, print);

    printf("Read '%s'\n", msg->string);

    /* Write a new message */
    msg = gsw_next_message(wb, print);

    strcpy(msg->string, "Hello, ");
    if (argc > 1)
        strcat(msg->string, argv[1]);
    else
        strcat(msg->string, "world!");

    gsw_increment(wb, print);
    gsw_increment_event_counter(wb, print);

    printf("Wrote '%s'\n", msg->string);

    /* Read the current whiteboard message */
    msg = gsw_current_message(wb, print);

    printf("Read '%s'\n", msg->string);

    return 0;
}