Home You are here: Home > Support > Reference v1.0

Change language: German

Hello World on console

Minimal console application

Before showing a small 'hello world' application for console the following sample show a minimal console application. This application does the initialization and start run the console io loop. The root object, which is connected to the main dialog have no properties, functions and sub object. So anything you can do in this 'dialog' is executing the commands of the exom shell.

#include "exom.h"
#include "exom_EvalKey.h"   // contain evaluation key

using namespace exom;

int main (int argc, char *argv[ ])
{
    if (!exomInit (exomKey))
        return 1;

    stdioLoop (XmPathRoot(), NULL);
    return 0;
}

The io loop in this small application will be active unless you leave with exit.

min_console.png

Output: minimal console application

'Hello world' application

Additional to the previous application this sample use the basics of the exom framework. These basisc are the exom::XmNamespace and an implementation of exom::XmObject. The namepace provide the IDs used by the object class. An instance of this class is connected to the main dialog.

#include "exom.h"
#include "exom_EvalKey.h"   // contain evaluation key

using namespace exom;

// Namespace providing two IDs used by MyClass
class MynsNamespace : public XmNamespace
{
  public:
    XmAtmID     ATM_TEST;
    XmObjID     OBJ_TEST;
    
    MynsNamespace ()
    {
        SetNamespaceNames ("myns_Namespace", "myns");
        SetAtm (ATM_TEST,         "ATM_TEST",   "testString");
        SetObj (OBJ_TEST,         "OBJ_TEST",   "testObject");
    }
};

MynsNamespace myns;  // namespace singleton

// Small test class with one string property 'testStr'
class MyClass : public XmObject
{
  public:
    XmString    testStr;
    XMOBJ       ObjectID () const       { return myns.OBJ_TEST; }
    void        manage (XmMan& m)   
    {
        m.manStr (testStr, myns.ATM_TEST);
    }
};

// main() function with initialization and console main loop
int main (int argc, char *argv[ ])
{
    if (!exomInit (exomKey))
        return 1;
    XmNamespaceMan::RegisterNamespace (myns);

    MyClass  myClass;
    myClass.testStr.AssignStr ("Hello World");

    stdioLoop (XmPathObj (&myClass), NULL);

    return 0;
}

When running the application you have the possibility to show and change the string property of the class instance. For learning and understanding the usage of the API try to add some more properties and subobjects or give the object class array functionality.

hello_world_console.png

Output: 'Hello World' for console


Copyright © 2006 Praetz Software Development - www.exomware.com