AAO DRAMA/DRAMA2 C++ Interface
dramahello.cpp
/* 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;
}

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:52 for AAO DRAMA/DRAMA2 C++ Interface by doxygen 1.8.10