AAO DRAMA/DRAMA2 C++ Interface
AAO DRAMA/DRAMA2 C++ Interface Documentation

This page is the front page for the documentation for the DRAMA 2 C++ interfaces to DRAMA.The core of DRAMA is written in C and was done well before C++ was available in a standard way on all the machines of interest. As a result, the C++ interfaces came later. There are a set of older C++ interfaces which have been distributed for some years, but which are a poor mapping to modern C++.

DRAMA2 provides a new C++ interface to DRAMA, interfaces which presume C++11 or later is available and makes extensive use of features of the upgraded compilers.

This documentation is generated automatically from the source code headers using the doxygen tool.

There is also a set of examples and a document describing how to use these interfaces - the document is the preferred way to learn DRAMA2. These are available in the AAO Module Drama2Examples. People outside the AAO can request these - please contact Tony Farrell

Below we have a quick introduction to each of the significant classes. There are various other minor classes and types.

Other classes documented are generally used to support one of the above classes.

The "Hello World" example is included below, but the document and its examples from the Drama2Examples module is probably the best way to learn DRAMA2.

/* D R A M A H E L L O
* Module name:
dramahello.cpp
* Function:
DRAMA 2 Hello World.
* Description:
Responds to the following commands
HELLO - Outputs message.
EXIT - Cause this task to exit.
* Language:
C++
* Copyright (c) Australian Astronomical Observatory, 2014.
Not to be used for commercial purposes without permission.
No warranty of any form unless subject to a specific agreement.
* Support: Tony Farrell, AAO
* @(#) $Id: ACMM:Drama2/examples/dramahello.cpp,v 1.45+ 22-Feb-2016 14:09:53+11 tjf $
*/
static const char *rcsId="@(#) $Id: ACMM:Drama2/examples/dramahello.cpp,v 1.45+ 22-Feb-2016 14:09:53+11 tjf $";
static void *use_rcsId = (0 ? (void *)(&use_rcsId) : (void *) &rcsId);
#include "drama.hh"
#include "drama/sds.hh"
class HelloAction : public drama::MessageHandler {
public:
HelloAction() {}
~HelloAction() {}
private:
/*
* Send a message to the user. (Method of MessageHandler)
*/
MessageUser("Hello World - from DRAMA 2");
/*
* Access any argument to this action.
* (GetEntry() is a method of MesageHandler.)
*/
if (Arg)
{
/*
* Print the argument.
*/
/*
* If the message is in standard format, the name
* of the first item will be Argument1.
*/
std::string MyArgument;
Arg.Get("Argument1", &MyArgument);
MessageUser(MyArgument);
/*
* Alternatively,
*/
}
/*
* Tell DRAMA the action has ended.
*/
}
};
class DramaHello : public drama::Task {
private:
HelloAction HelloActionObj;
public:
DramaHello() : drama::Task("DRAMAHELLO") {
Add("HELLO", drama::MessageHandlerPtr(&HelloActionObj, drama::nodel()));
}
~DramaHello() {
}
};
int main()
{
try
{
// Make this program a DRAMA task named ticker
DramaHello task;
// Process DRAMA messages.
task.RunDrama();
}
catch (drama::Exception &e)
{
fprintf(stderr,"DRAMA Exception thrown and caught in main\n");
fprintf(stderr,"%s\n", e.toString().c_str());
fprintf(stderr,"DRAMA Status = 0X%lx, %s\n",
static_cast<long int>(e.dramaStatus()),
e.dramaStatusStr().c_str());
exit (e.statusAsSysExitCode());
}
return 0;
}
Author
Tony Farrell, AAO
Revision
1.45
Date
22-Feb-2016 14:09:53+11

Click here for the DRAMA home page and here for the AAO home page.

For more information, contact tjf@aao.gov.au 

Generated on Mon Feb 22 2016 15:57:53 for AAO DRAMA/DRAMA2 C++ Interface by doxygen 1.8.10