diff options
14 files changed, 2990 insertions, 0 deletions
diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ConfigurableEC.cpp b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ConfigurableEC.cpp new file mode 100644 index 00000000000..59a6f9faf14 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ConfigurableEC.cpp @@ -0,0 +1,98 @@ +// $Id$ + +#include "ace/Get_Opt.h" +#include "ACEXML/parser/parser/Parser.h" +#include "ACEXML/common/InputSource.h" +#include "ACEXML/common/FileCharStream.h" +#include "ACEXML/common/DefaultHandler.h" + +#include "Configurator_ParseHandler.h" + +struct Arguments +{ + ACE_CString filename_; +}; + +int parse_args (int argc, char *argv[],Arguments &args); + +int +main (int argc, char *argv[]) +{ + int retval; + + ACEXML_TRY_NEW_ENV + { + ACEXML_Parser parser; + Arguments args; + args.filename_.set(ACE_TEXT("test.xml")); + + // parse args for config filename + if (parse_args(argc,argv,args) == -1) + { + return 1; + } + + ACEXML_FileCharStream *fcs = new ACEXML_FileCharStream(); + if ((retval = fcs->open(args.filename_.c_str())) != 0) { + //ACE_DEBUG ((LM_DEBUG, "Could not open file %s\n",args.filename_.c_str())); + return retval; + } + + ACEXML_InputSource is (fcs); //takes responsibility of fcs + + Configurator_ParseHandler xmlhandler (args.filename_.c_str()); + ACEXML_DefaultHandler dflt; + + parser.setContentHandler (&xmlhandler); + parser.setDTDHandler (&dflt); + parser.setErrorHandler (&xmlhandler); + parser.setEntityResolver (&dflt); + + parser.parse(&is); + ACEXML_TRY_CHECK; + + if ((retval = fcs->close()) != 0) { + //ACE_DEBUG ((LM_DEBUG, "Could not close file %s\n",args.filename_.c_str())); + return retval; + } + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Finished parsing\n"))); + + } + ACEXML_CATCH (ACEXML_SAXException, ex) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Exception occurred: %s. Exiting...\n"), + ex.message())); + return 1; + } + ACEXML_ENDTRY; + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Finished successfully\n"))); + + return retval; +} + +int parse_args (int argc, char *argv[], Arguments &args) +{ + ACE_Get_Opt get_opts (argc, argv, "f:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'f': + args.filename_.set(get_opts.opt_arg()); + //ACE_DEBUG((LM_DEBUG,ACE_TEXT("Filename argument: %s\n"),args.filename_.c_str())); + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "[-f <filename>] " + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.cpp b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.cpp new file mode 100644 index 00000000000..e869619e065 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.cpp @@ -0,0 +1,1115 @@ +// -*- C++ -*- $Id$ + +#include "Configurator_ParseHandler.h" +#include "SyntaxTree.h" + +#include "ace/ACE.h" +#include "ace/Log_Msg.h" +#include "ace/OS_String.h" + +#include "RtecSchedulerC.h" + +#include <stdlib.h> //for atol +#include <sstream> //for istringstream + +Configurator_ParseHandler::Configurator_ParseHandler (const char *filename) + : fileName_(filename) + , ecconfiguration(0) +{ +} + +Configurator_ParseHandler::~Configurator_ParseHandler (void) +{ +} + +void +Configurator_ParseHandler::characters (const ACEXML_Char * cdata, + int , + int + ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + //ACE_UNUSED_ARG(cdata); + + if (!this->scope_.empty()) + { + std::istringstream iss(cdata); + + switch (this->scope_.top()->getSyntaxType()) + { + IntegerSyntax *intsyn; + StringSyntax *strsyn; + + case VisitableSyntax::WORSTEXECUTION: + case VisitableSyntax::TYPICALEXECUTION: + case VisitableSyntax::PERIOD: + case VisitableSyntax::PHASE: + case VisitableSyntax::TIME: + case VisitableSyntax::VALUE: + intsyn = dynamic_cast<IntegerSyntax*>(this->scope_.top()); + if ((iss >> intsyn->val) == 0) + { + ACEXML_THROW(ACEXML_SAXException(ACE_TEXT ("Invalid number format"))); + } + break; + case VisitableSyntax::EVENTNAME: + case VisitableSyntax::SUPPLIERNAME: + case VisitableSyntax::TIMEOUTNAME: + case VisitableSyntax::IORFILE: + strsyn = dynamic_cast<StringSyntax*>(this->scope_.top()); + strsyn->str.set(iss.str().c_str()); + break; + case VisitableSyntax::ECCONFIGURATION: + case VisitableSyntax::EVENT: + case VisitableSyntax::CRITICALITY: + case VisitableSyntax::IMPORTANCE: + case VisitableSyntax::TIMEOUT: + case VisitableSyntax::LOCALEVENTCHANNEL: + case VisitableSyntax::REMOTEEVENTCHANNEL: + case VisitableSyntax::SCHEDULINGSTRATEGY: + case VisitableSyntax::CONSUMER: + case VisitableSyntax::SUBSCRIPTIONS: + case VisitableSyntax::DEPENDANTS: + case VisitableSyntax::SUPPLIER: + case VisitableSyntax::PUBLICATIONS: + case VisitableSyntax::TRIGGERS: + case VisitableSyntax::TESTDRIVER: + case VisitableSyntax::STARTCONDITION: + case VisitableSyntax::STOPCONDITION: + case VisitableSyntax::UNKNOWN_ELEMENT: + default: + //ignore characters outside leaf elements + break; + } + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Character data outside of any scope"))); + } +} + +void +Configurator_ParseHandler::endDocument (ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + /* + // Print out test_config_t's: + const TestConfig::Test_Config_Set &cfgs = *this->configs_; + char *cfg_format = "{%10d, %10d, %10d, %10d, %10d }"; + + for (size_t i=0; i<cfgs.size(); ++i) { + TestConfig::test_config_t *cfg = cfgs[i]; + + if (i!=0) + { + //finish previous line + ACE_DEBUG ((LM_DEBUG, "\n")); + } + if (cfg->comptype == TestConfig::SOURCE) + { + ACE_DEBUG ((LM_DEBUG, "SOURCE : ")); + } + else if (cfg->comptype == TestConfig::SINK) + { + ACE_DEBUG ((LM_DEBUG, "SINK : ")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "UNKNOWN: ")); + } + ACE_DEBUG ((LM_DEBUG, cfg_format, + cfg->type, + cfg->period, + cfg->criticality, + cfg->importance, + cfg->num_entities)); + } + //finish last line + ACE_DEBUG ((LM_DEBUG, "\n")); + */ +} + +void +Configurator_ParseHandler::endElement (const ACEXML_Char *namespaceURI, + const ACEXML_Char *localName, + const ACEXML_Char *qName + ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + /* + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("* Event endElement (%s, %s, %s) ***************\n"), + namespaceURI, localName, qName)); + */ + + ACE_UNUSED_ARG(namespaceURI); + ACE_UNUSED_ARG(localName); + ACE_UNUSED_ARG(qName); + + if (this->scope_.empty() == 1) + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Element end outside of any scope"))); + } + else + { + this->scope_.pop(); + } + +} + +void +Configurator_ParseHandler::endPrefixMapping (const ACEXML_Char * + ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // no-op +} + +void +Configurator_ParseHandler::ignorableWhitespace (const ACEXML_Char *, + int, + int + ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // no-op +} + +void +Configurator_ParseHandler::processingInstruction (const ACEXML_Char *, + const ACEXML_Char * + ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // no-op +} + +void +Configurator_ParseHandler::setDocumentLocator (ACEXML_Locator * locator) +{ + this->locator_ = locator; +} + +void +Configurator_ParseHandler::skippedEntity (const ACEXML_Char * + ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // no-op +} + +void +Configurator_ParseHandler::startDocument (ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // no-op +} + +void +Configurator_ParseHandler::startElement (const ACEXML_Char *uri, + const ACEXML_Char *name, + const ACEXML_Char *qName, + ACEXML_Attributes *alist + ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("* Event startElement (%s, %s, %s) ***************\n"), + uri, name, qName)); + /* + if (alist != 0) + for (size_t i = 0; i < alist->getLength (); ++i) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT (" %s = \"%s\"\n"), + alist->getQName (i), alist->getValue (i))); + } + */ + + ACE_UNUSED_ARG(uri); + ACE_UNUSED_ARG(name); + + VisitableSyntax *syn = 0; + + if (ACE_OS_String::strcmp (qName, ACE_TEXT ("ECConfiguration")) == 0) + { + ACE_NEW(syn,ECConfiguration); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("Event")) == 0) + { + ACE_NEW(syn,Event); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("Criticality")) == 0) + { + ACE_NEW(syn,Criticality); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("Importance")) == 0) + { + ACE_NEW(syn,Importance); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("WorstExecution")) == 0) + { + ACE_NEW(syn,WorstExecution); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("TypicalExecution")) == 0) + { + ACE_NEW(syn,TypicalExecution); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("Timeout")) == 0) + { + ACE_NEW(syn,Timeout); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("Period")) == 0) + { + ACE_NEW(syn,Period); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("Phase")) == 0) + { + ACE_NEW(syn,Phase); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("LocalEventChannel")) == 0) + { + ACE_NEW(syn,LocalEventChannel); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("RemoteEventChannel")) == 0) + { + ACE_NEW(syn,RemoteEventChannel); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("SchedulingStrategy")) == 0) + { + ACE_NEW(syn,SchedulingStrategy); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("Consumer")) == 0) + { + ACE_NEW(syn,Consumer); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("Subscriptions")) == 0) + { + ACE_NEW(syn,Subscriptions); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("EventName")) == 0) + { + ACE_NEW(syn,EventName); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("Dependants")) == 0) + { + ACE_NEW(syn,Dependants); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("SupplierName")) == 0) + { + ACE_NEW(syn,SupplierName); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("Supplier")) == 0) + { + ACE_NEW(syn,Supplier); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("Publications")) == 0) + { + ACE_NEW(syn,Publications); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("Triggers")) == 0) + { + ACE_NEW(syn,Triggers); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("TimeoutName")) == 0) + { + ACE_NEW(syn,TimeoutName); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("IORFile")) == 0) + { + ACE_NEW(syn,IORFile); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("TestDriver")) == 0) + { + ACE_NEW(syn,TestDriver); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("StartCondition")) == 0) + { + ACE_NEW(syn,StartCondition); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("Time")) == 0) + { + ACE_NEW(syn,Time); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("StopCondition")) == 0) + { + ACE_NEW(syn,StopCondition); + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("Value")) == 0) + { + ACE_NEW(syn,Value); + } + else + { + ACE_CString error("Element start of unknown type: "); + error += qName; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + + syn->visit(this,alist); +} + +void +Configurator_ParseHandler::startPrefixMapping (const ACEXML_Char *, + const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // no-op +} + +// Methods inherited from ACEXML_ErrorHandler. + +/* + * Receive notification of a recoverable error. + */ +void +Configurator_ParseHandler::error (ACEXML_SAXParseException & ex ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + + ACE_DEBUG ((LM_DEBUG, "%s:%d:%d ", this->fileName_.c_str(), + this->locator_->getLineNumber(), + this->locator_->getColumnNumber())); + ex.print(); +} + +void +Configurator_ParseHandler::fatalError (ACEXML_SAXParseException& ex ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + + ACE_DEBUG ((LM_DEBUG, "%s:%d:%d ", this->fileName_.c_str(), + this->locator_->getLineNumber(), + this->locator_->getColumnNumber())); + ex.print(); +} + +void +Configurator_ParseHandler::warning (ACEXML_SAXParseException & ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // No-op. +} + +// SyntaxVisitor FUNCTIONS // + +int +Configurator_ParseHandler::parseVisitableSyntax (VisitableSyntax* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + ACE_CString error("Unknown syntax token: "); + char errbuf[MAXTYPESTRINGLEN]; + visitableTypeToString(vs->getSyntaxType(),errbuf,MAXTYPESTRINGLEN); + error += errbuf; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + return 0; +} + +int +Configurator_ParseHandler::parseECConfiguration (ECConfiguration* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + this->ecconfiguration = vs; + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseEvent (Event* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::ECCONFIGURATION) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Event not child of ECConfiguration"))); + + ACEXML_Attributes *alist = static_cast<ACEXML_Attributes*>(arg); + const ACEXML_Char *val = alist->getValue(ACE_TEXT("name")); + if (val != 0) + { + vs->name = val; + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for Event"))); + } + + ECConfiguration *parent = dynamic_cast<ECConfiguration*> (this->scope_.top()); + parent->events.push_back(vs); + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseCriticality (Criticality* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Criticality not child of Event"))); + + ACEXML_Attributes *alist = static_cast<ACEXML_Attributes*>(arg); + const ACEXML_Char *val = alist->getValue(ACE_TEXT("value")); + if (val != 0) + { + if (ACE_OS_String::strcmp(val,ACE_TEXT("VERY_LOW")) == 0) + { + vs->value = RtecScheduler::VERY_LOW_CRITICALITY; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("LOW")) == 0) + { + vs->value = RtecScheduler::LOW_CRITICALITY; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("MEDIUM")) == 0) + { + vs->value = RtecScheduler::MEDIUM_CRITICALITY; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("HIGH")) == 0) + { + vs->value = RtecScheduler::HIGH_CRITICALITY; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("VERY_HIGH")) == 0) + { + vs->value = RtecScheduler::VERY_HIGH_CRITICALITY; + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid value for \"value\"" + " attribute for Criticality"))); + } + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for Criticality"))); + } + + Event *parent = dynamic_cast<Event*> (this->scope_.top()); + parent->criticality = vs; + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseImportance (Importance* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Importance not child of Event"))); + + ACEXML_Attributes *alist = static_cast<ACEXML_Attributes*>(arg); + const ACEXML_Char *val = alist->getValue(ACE_TEXT("value")); + if (val != 0) + { + if (ACE_OS_String::strcmp(val,ACE_TEXT("VERY_LOW")) == 0) + { + vs->value = RtecScheduler::VERY_LOW_IMPORTANCE; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("LOW")) == 0) + { + vs->value = RtecScheduler::LOW_IMPORTANCE; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("MEDIUM")) == 0) + { + vs->value = RtecScheduler::MEDIUM_IMPORTANCE; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("HIGH")) == 0) + { + vs->value = RtecScheduler::HIGH_IMPORTANCE; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("VERY_HIGH")) == 0) + { + vs->value = RtecScheduler::VERY_HIGH_IMPORTANCE; + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid value for \"value\"" + " attribute for Importance"))); + } + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for Importance"))); + } + + Event *parent = dynamic_cast<Event*> (this->scope_.top()); + parent->importance = vs; + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseTimeout (Timeout* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::ECCONFIGURATION) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Timeout not a child of ECConfiguration"))); + + ACEXML_Attributes *alist = static_cast<ACEXML_Attributes*>(arg); + const ACEXML_Char *val = alist->getValue(ACE_TEXT("name")); + if (val != 0) + { + vs->name = val; + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for Timeout"))); + } + + ECConfiguration *parent = dynamic_cast<ECConfiguration*> (this->scope_.top()); + parent->timeouts.push_back(vs); + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseLocalEventChannel (LocalEventChannel* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::ECCONFIGURATION) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("LocalEventChannel not child of ECConfiguration"))); + + ACEXML_Attributes *alist = static_cast<ACEXML_Attributes*>(arg); + const ACEXML_Char *val = alist->getValue(ACE_TEXT("name")); + if (val != 0) + { + vs->name = val; + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for LocalEventChannel"))); + } + + ECConfiguration *parent = dynamic_cast<ECConfiguration*> (this->scope_.top()); + parent->localECs.push_back(vs); + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseRemoteEventChannel (RemoteEventChannel* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::ECCONFIGURATION) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("RemoteEventChannel not child of ECConfiguration"))); + + ACEXML_Attributes *alist = static_cast<ACEXML_Attributes*>(arg); + const ACEXML_Char *val = alist->getValue(ACE_TEXT("name")); + if (val != 0) + { + vs->name = val; + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for LocalEventChannel"))); + } + + ECConfiguration *parent = dynamic_cast<ECConfiguration*> (this->scope_.top()); + parent->remoteECs.push_back(vs); + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseSchedulingStrategy (SchedulingStrategy* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::LOCALEVENTCHANNEL) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("SchedulingStrategy not child of LocalEventChannel"))); + + ACEXML_Attributes *alist = static_cast<ACEXML_Attributes*>(arg); + const ACEXML_Char *val = alist->getValue(ACE_TEXT("type")); + if (val != 0) + { + if (ACE_OS_String::strcmp(val,ACE_TEXT("EDF")) == 0) + { + vs->type = SchedulingStrategy::EDF; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("MUF")) == 0) + { + vs->type = SchedulingStrategy::MUF; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("RMS")) == 0) + { + vs->type = SchedulingStrategy::RMS; + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attribute \"type\" for SchedulingStrategy"))); + } + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for LocalEventChannel"))); + } + val = alist->getValue(ACE_TEXT("enableRG")); + if (val != 0) + { + if (ACE_OS_String::strcmp(val,ACE_TEXT("yes")) == 0) + { + vs->enableRG = true; + } + else + { + vs->enableRG = false; + } + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for LocalEventChannel"))); + } + + LocalEventChannel *parent = dynamic_cast<LocalEventChannel*> (this->scope_.top()); + parent->schedulingstrategy = vs; + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseConsumer (Consumer* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::LOCALEVENTCHANNEL + || this->scope_.top()->getSyntaxType() != VisitableSyntax::REMOTEEVENTCHANNEL) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Consumer not child of LocalEventChannel or RemoteEventChannel"))); + + ACEXML_Attributes *alist = static_cast<ACEXML_Attributes*>(arg); + const ACEXML_Char *val = alist->getValue(ACE_TEXT("name")); + if (val != 0) + { + vs->name = val; + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for Consumer"))); + } + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::LOCALEVENTCHANNEL) + { + LocalEventChannel *parent = dynamic_cast<LocalEventChannel*> (this->scope_.top()); + parent->consumers.push_back(vs); + } + else // must be RemoteEventChannel + { + RemoteEventChannel *parent = dynamic_cast<RemoteEventChannel*> (this->scope_.top()); + parent->consumers.push_back(vs); + } + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseSubscriptions (Subscriptions* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::CONSUMER) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Subscriptions not child of Consumer"))); + + Consumer *parent = dynamic_cast<Consumer*> (this->scope_.top()); + parent->subscriptions = vs; + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseDependants (Dependants* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::CONSUMER) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Dependants not child of Consumer"))); + + Consumer *parent = dynamic_cast<Consumer*> (this->scope_.top()); + parent->dependants = vs; + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseSupplier (Supplier* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::LOCALEVENTCHANNEL + || this->scope_.top()->getSyntaxType() != VisitableSyntax::REMOTEEVENTCHANNEL) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Supplier not child of LocalEventChannel"))); + + ACEXML_Attributes *alist = static_cast<ACEXML_Attributes*>(arg); + const ACEXML_Char *val = alist->getValue(ACE_TEXT("name")); + if (val != 0) + { + vs->name = val; + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for Supplier"))); + } + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::LOCALEVENTCHANNEL) + { + LocalEventChannel *parent = dynamic_cast<LocalEventChannel*> (this->scope_.top()); + parent->suppliers.push_back(vs); + } + else // must be RemoteEventChannel + { + RemoteEventChannel *parent = dynamic_cast<RemoteEventChannel*> (this->scope_.top()); + parent->suppliers.push_back(vs); + } + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parsePublications (Publications* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::SUPPLIER) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Publications not child of Supplier"))); + + Supplier *parent = dynamic_cast<Supplier*> (this->scope_.top()); + parent->publications = vs; + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseTriggers (Triggers* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::SUPPLIER) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Triggers not child of Supplier"))); + + Supplier *parent = dynamic_cast<Supplier*> (this->scope_.top()); + parent->triggers = vs; + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseTestDriver (TestDriver* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::ECCONFIGURATION) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("TestDriver not child of ECConfiguration"))); + + ECConfiguration *parent = dynamic_cast<ECConfiguration*> (this->scope_.top()); + parent->driver = vs; + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseStartCondition (StartCondition* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::TESTDRIVER) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("StartCondition not child of TestDriver"))); + + ACEXML_Attributes *alist = static_cast<ACEXML_Attributes*>(arg); + const ACEXML_Char *val = alist->getValue(ACE_TEXT("type")); + if (val != 0) + { + if (ACE_OS_String::strcmp(val,ACE_TEXT("GlobalTime")) == 0) + { + vs->type = StartCondition::GLOBALTIME; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("DelayAfterStart")) == 0) + { + vs->type = StartCondition::DELAYAFTERSTART; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("DelayAfterConnect")) == 0) + { + vs->type = StartCondition::DELAYAFTERCONNECT; + } + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for StartCondition"))); + } + val = alist->getValue(ACE_TEXT("master")); + if (val != 0) + { + if (ACE_OS_String::strcmp(val,ACE_TEXT("yes")) == 0) + { + vs->master = true; + } + else + { + vs->master = false; + } + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for StartCondition"))); + } + + TestDriver *parent = dynamic_cast<TestDriver*> (this->scope_.top()); + parent->startcondition = vs; + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseStopCondition (StopCondition* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::TESTDRIVER) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("StopCondition not child of TestDriver"))); + + ACEXML_Attributes *alist = static_cast<ACEXML_Attributes*>(arg); + const ACEXML_Char *val = alist->getValue(ACE_TEXT("type")); + if (val != 0) + { + if (ACE_OS_String::strcmp(val,ACE_TEXT("Duration")) == 0) + { + vs->type = StopCondition::DURATION; + } + else + { + vs->type = StopCondition::EVENTNUMBER; + } + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for StopCondition"))); + } + + TestDriver *parent = dynamic_cast<TestDriver*> (this->scope_.top()); + parent->stopcondition = vs; + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseEventName (EventName* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::SUBSCRIPTIONS + || this->scope_.top()->getSyntaxType() != VisitableSyntax::PUBLICATIONS + || this->scope_.top()->getSyntaxType() != VisitableSyntax::TRIGGERS) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("EventName not child of Subscriptions, Publications, or Triggers"))); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::SUBSCRIPTIONS) + { + Subscriptions *parent = dynamic_cast<Subscriptions*> (this->scope_.top()); + parent->eventnames.push_back(vs); + } + else if (this->scope_.top()->getSyntaxType() != VisitableSyntax::PUBLICATIONS) + { + Publications *parent = dynamic_cast<Publications*> (this->scope_.top()); + parent->eventnames.push_back(vs); + } + else if (this->scope_.top()->getSyntaxType() != VisitableSyntax::TRIGGERS) + { + Triggers *parent = dynamic_cast<Triggers*> (this->scope_.top()); + parent->eventnames.push_back(vs); + } + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseSupplierName (SupplierName* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::DEPENDANTS) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("SupplierName not child of Dependants"))); + + Dependants *parent = dynamic_cast<Dependants*> (this->scope_.top()); + parent->suppliernames.push_back(vs); + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseTimeoutName (TimeoutName* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::TRIGGERS) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("TimeoutName not child of Triggers"))); + + Triggers *parent = dynamic_cast<Triggers*> (this->scope_.top()); + parent->timeoutnames.push_back(vs); + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseIORFile (IORFile* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::REMOTEEVENTCHANNEL) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("IORFile not child of RemoteEventChannel"))); + + RemoteEventChannel *parent = dynamic_cast<RemoteEventChannel*> (this->scope_.top()); + parent->iorfile = vs; + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseWorstExecution (WorstExecution* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("WorstExecution not child of Event"))); + + Event *parent = dynamic_cast<Event*> (this->scope_.top()); + parent->worstexecution = vs; + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseTypicalExecution (TypicalExecution* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("TypicalExecution not child of Event"))); + + Event *parent = dynamic_cast<Event*> (this->scope_.top()); + parent->typicalexecution = vs; + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parsePeriod (Period* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT + || this->scope_.top()->getSyntaxType() != VisitableSyntax::TIMEOUT) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Period not child of Event or Timeout"))); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT) + { + Event *parent = dynamic_cast<Event*> (this->scope_.top()); + parent->period = vs; + } + else if (this->scope_.top()->getSyntaxType() != VisitableSyntax::TIMEOUT) + { + Timeout *parent = dynamic_cast<Timeout*> (this->scope_.top()); + parent->period = vs; + } + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parsePhase (Phase* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT + || this->scope_.top()->getSyntaxType() != VisitableSyntax::TIMEOUT) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Phase not child of Event or Timeout"))); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT) + { + Event *parent = dynamic_cast<Event*> (this->scope_.top()); + parent->phase = vs; + } + else if (this->scope_.top()->getSyntaxType() != VisitableSyntax::TIMEOUT) + { + Timeout *parent = dynamic_cast<Timeout*> (this->scope_.top()); + parent->phase = vs; + } + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseTime (Time* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::STARTCONDITION) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Time not child of StartCondition"))); + + StartCondition *parent = dynamic_cast<StartCondition*> (this->scope_.top()); + parent->time = vs; + + this->scope_.push(vs); + return 0; +} + +int +Configurator_ParseHandler::parseValue (Value* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::STOPCONDITION) + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Value not child of StopCondition"))); + + StopCondition *parent = dynamic_cast<StopCondition*> (this->scope_.top()); + parent->value = vs; + + this->scope_.push(vs); + return 0; +} + +VisitableSyntax* +Configurator_ParseHandler::getRootNode (void) +{ + return this->ecconfiguration; +} diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.h b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.h new file mode 100644 index 00000000000..842dd8db11c --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.h @@ -0,0 +1,243 @@ +// $Id$ + +//============================================================================= +/** + * @file Configurator_ParseHandler.h + * + * $Id$ + * + * @author Bryan Thrall <thrall@cse.wustl.edu> + */ +//============================================================================= + + +#ifndef CONFIGURATOR_PARSEHANDLER_H +#define CONFIGURATOR_PARSEHANDLER_H + +#include "ace/String_Base.h" +#include "ACEXML/common/ContentHandler.h" +#include "ACEXML/common/ErrorHandler.h" + +#include <stack> + +#include "SyntaxVisitor.h" +#include "SyntaxTree.h" + +//TODO: We need a name table. If name order shouldn't matter, we're +//going to need two passes: one to get the names and one to parse the +//rest of the XML. + +//TODO: An element/attribute tag database would be helpful for adding +//new stuff (make this class more generic) and if tag names change. +//We could hardcode it into setup or have it parse the DTD. + +/** + * @class Configurator_ParseHandler + * + * @brief Configurator_ParseHandler is a SAX event handler which + * parses ecconfig.dtd XML + * + * This SAX event handler parses XML according to ecconfig.dtd, + * producing a set of test_config_t's. + */ +class Configurator_ParseHandler : public ACEXML_ContentHandler, + public ACEXML_ErrorHandler, + public SyntaxVisitor +{ +public: + + typedef std::stack<VisitableSyntax*> STACK; + + /* + * Default constructor. + */ + Configurator_ParseHandler (const char *filename); + + /* + * Default destructor. + */ + virtual ~Configurator_ParseHandler (void); + + // Methods inherited from ACEXML_ContentHandler. + + /* + * Receive notification of character data. + */ + virtual void characters (const ACEXML_Char *ch, + int start, + int length ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of the end of a document. + */ + virtual void endDocument (ACEXML_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of the end of an element. + */ + virtual void endElement (const ACEXML_Char *namespaceURI, + const ACEXML_Char *localName, + const ACEXML_Char *qName ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * End the scope of a prefix-URI mapping. + */ + virtual void endPrefixMapping (const ACEXML_Char *prefix ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of ignorable whitespace in element content. + */ + virtual void ignorableWhitespace (const ACEXML_Char *ch, + int start, + int length ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of a processing instruction. + */ + virtual void processingInstruction (const ACEXML_Char *target, + const ACEXML_Char *data ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive an object for locating the origin of SAX document events. + */ + virtual void setDocumentLocator (ACEXML_Locator *locator) ; + + /* + * Receive notification of a skipped entity. + */ + virtual void skippedEntity (const ACEXML_Char *name ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of the beginning of a document. + */ + virtual void startDocument (ACEXML_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of the beginning of an element. + */ + virtual void startElement (const ACEXML_Char *namespaceURI, + const ACEXML_Char *localName, + const ACEXML_Char *qName, + ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Begin the scope of a prefix-URI Namespace mapping. + */ + virtual void startPrefixMapping (const ACEXML_Char *prefix, + const ACEXML_Char *uri ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + // Methods inherited from ACEXML_ErrorHandler. + + /* + * Receive notification of a recoverable error. + */ + virtual void error (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of a non-recoverable error. + */ + virtual void fatalError (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of a warning. + */ + virtual void warning (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + virtual int parseVisitableSyntax (VisitableSyntax *vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + + virtual int parseECConfiguration (ECConfiguration* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseEvent (Event* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseCriticality (Criticality* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseImportance (Importance* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseTimeout (Timeout* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseLocalEventChannel (LocalEventChannel* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseRemoteEventChannel (RemoteEventChannel* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseSchedulingStrategy (SchedulingStrategy* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseConsumer (Consumer* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseSubscriptions (Subscriptions* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseDependants (Dependants* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseSupplier (Supplier* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parsePublications (Publications* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseTriggers (Triggers* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseTestDriver (TestDriver* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseStartCondition (StartCondition* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseStopCondition (StopCondition* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + + virtual int parseEventName (EventName* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseSupplierName (SupplierName* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseTimeoutName (TimeoutName* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseIORFile (IORFile* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseWorstExecution (WorstExecution* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseTypicalExecution (TypicalExecution* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parsePeriod (Period* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parsePhase (Phase* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseTime (Time* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseValue (Value* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + + virtual VisitableSyntax* getRootNode (void); + +private: + + ACE_CString fileName_; + ACEXML_Locator* locator_; + + STACK scope_; + + ECConfiguration *ecconfiguration; +}; + +#endif /* CONFIGURATOR_PARSEHANDLER_H */ diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.cpp b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.cpp new file mode 100644 index 00000000000..5d5967b99a3 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.cpp @@ -0,0 +1,320 @@ +// -*- C++ -*- $Id$ + +#include "Configurator_SyntaxHandler.h" +#include "SyntaxTree.h" + +#include "ace/ACE.h" +#include "ace/Log_Msg.h" +#include "ace/OS_String.h" + +#include "RtecSchedulerC.h" + +#include <stdlib.h> //for atol +#include <sstream> //for istringstream + +Configurator_SyntaxHandler::Configurator_SyntaxHandler (void) + : root(0) +{ +} + +Configurator_SyntaxHandler::~Configurator_SyntaxHandler (void) +{ +} + +// SyntaxVisitor FUNCTIONS // + +int +Configurator_SyntaxHandler::parseVisitableSyntax (VisitableSyntax* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(arg); + + ACE_CString error("Unknown syntax token: "); + char errbuf[MAXTYPESTRINGLEN]; + visitableTypeToString(vs->getSyntaxType(),errbuf,MAXTYPESTRINGLEN); + error += errbuf; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + return 0; +} + +int +Configurator_SyntaxHandler::parseECConfiguration (ECConfiguration* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseEvent (Event* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseCriticality (Criticality* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseImportance (Importance* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseTimeout (Timeout* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseLocalEventChannel (LocalEventChannel* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseRemoteEventChannel (RemoteEventChannel* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseSchedulingStrategy (SchedulingStrategy* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseConsumer (Consumer* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseSubscriptions (Subscriptions* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseDependants (Dependants* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseSupplier (Supplier* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parsePublications (Publications* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseTriggers (Triggers* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseTestDriver (TestDriver* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseStartCondition (StartCondition* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseStopCondition (StopCondition* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseEventName (EventName* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseSupplierName (SupplierName* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseTimeoutName (TimeoutName* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseIORFile (IORFile* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseWorstExecution (WorstExecution* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseTypicalExecution (TypicalExecution* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parsePeriod (Period* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parsePhase (Phase* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseTime (Time* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +int +Configurator_SyntaxHandler::parseValue (Value* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG(vs); + ACE_UNUSED_ARG(arg); + + return 0; +} + +VisitableSyntax* +Configurator_SyntaxHandler::getRootNode (void) +{ + return this->root; +} + +void +Configurator_SyntaxHandler::setRootNode (VisitableSyntax *vs) +{ + this->root = vs; +} diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.h b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.h new file mode 100644 index 00000000000..8892d3c40b6 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.h @@ -0,0 +1,111 @@ +// $Id$ + +//============================================================================= +/** + * @file Configurator_SyntaxHandler.h + * + * $Id$ + * + * @author Bryan Thrall <thrall@cse.wustl.edu> + */ +//============================================================================= + + +#ifndef CONFIGURATOR_SYNTAXHANDLER_H +#define CONFIGURATOR_SYNTAXHANDLER_H + +#include "ACEXML/common/SAXExceptions.h" + +#include "SyntaxVisitor.h" +#include "SyntaxTree.h" + +/** + * @class Configurator_SyntaxHandler + * + * @brief Configurator_SyntaxHandler configures the EC based on a + * syntax tree produced by Configurator_ParseHandler. + * + */ +class Configurator_SyntaxHandler : public SyntaxVisitor +{ +public: + + /* + * Default constructor. + */ + Configurator_SyntaxHandler (void); + + /* + * Default destructor. + */ + virtual ~Configurator_SyntaxHandler (void); + + virtual int parseVisitableSyntax (VisitableSyntax *vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + + virtual int parseECConfiguration (ECConfiguration* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseEvent (Event* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseCriticality (Criticality* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseImportance (Importance* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseTimeout (Timeout* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseLocalEventChannel (LocalEventChannel* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseRemoteEventChannel (RemoteEventChannel* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseSchedulingStrategy (SchedulingStrategy* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseConsumer (Consumer* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseSubscriptions (Subscriptions* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseDependants (Dependants* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseSupplier (Supplier* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parsePublications (Publications* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseTriggers (Triggers* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseTestDriver (TestDriver* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseStartCondition (StartCondition* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseStopCondition (StopCondition* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + + virtual int parseEventName (EventName* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseSupplierName (SupplierName* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseTimeoutName (TimeoutName* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseIORFile (IORFile* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseWorstExecution (WorstExecution* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseTypicalExecution (TypicalExecution* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parsePeriod (Period* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parsePhase (Phase* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseTime (Time* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual int parseValue (Value* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)); + + virtual VisitableSyntax* getRootNode (void); + + virtual void setRootNode(VisitableSyntax *vs); + +private: + + VisitableSyntax *root; +}; + +#endif /* CONFIGURATOR_SYNTAXHANDLER_H */ diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.cpp b/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.cpp new file mode 100644 index 00000000000..9f776c2fad3 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.cpp @@ -0,0 +1,49 @@ +// -*- C++ -*- $Id$ + +#include "SyntaxTree.h" + +//Copies as much of the type name to the buffer as fits; buf will null-term. +void visitableTypeToString (VisitableSyntax::element type, char *buf, int buflen) { + if (buflen <= 0) return; + + char* typestr[] = { + "ECCONFIGURATION", + "EVENT", + "CRITICALITY", + "IMPORTANCE", + "WORSTEXECUTION", + "TYPICALEXECUTION", + "TIMEOUT", + "PERIOD", + "PHASE", + "LOCALEVENTCHANNEL", + "REMOTEEVENTCHANNEL", + "SCHEDULINGSTRATEGY", + "CONSUMER", + "SUBSCRIPTIONS", + "EVENTNAME", + "DEPENDANTS", + "SUPPLIERNAME", + "SUPPLIER", + "PUBLICATIONS", + "TRIGGERS", + "TIMEOUTNAME", + "IORFILE", + "TESTDRIVER", + "STARTCONDITION", + "TIME", + "STOPCONDITION", + "VALUE", + "UNKNOWN_ELEMENT" + }; + //assume type is just index + char *str = typestr[type]; + + //copy over type string + for(int i=0; i<buflen-1; ++i) { + buf[i] = str[i]; + if (str[i] == '\0') + return; + } + buf[buflen-1] = '\0'; //null terminate +} diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.h b/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.h new file mode 100644 index 00000000000..67a892f1478 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.h @@ -0,0 +1,714 @@ +// $Id$ + +//============================================================================= +/** + * @file SyntaxTree.h + * + * $Id$ + * + * @author Bryan Thrall <thrall@cse.wustl.edu> + */ +//============================================================================= + + +#ifndef SYNTAXTREE_H +#define SYNTAXTREE_H + +#include "SyntaxVisitor.h" + +#include "RtecSchedulerC.h" +#include "ace/OS_String.h" + +#include <vector> + +// Forward decls +class VisitableSyntax; +class StringSyntax; +class IntegerSyntax; +class Driver; +class ECConfiguration; +class Event; +class Criticality; +class Importance; +class Timeout; +class LocalEventChannel; +class RemoteEventChannel; +class SchedulingStrategy; +class Consumer; +class Subscriptions; +class Dependants; +class Supplier; +class Publications; +class Triggers; +class TestDriver; +class StartCondition; +class StopCondition; +class EventName; +class SupplierName; +class TimeoutName; +class IORFile; +class WorstExecution; +class TypicalExecution; +class Period; +class Phase; +class Time; +class Value; + +// Utility classes + +class VisitableSyntax +{ +public: + + //Tag for the element type + enum element { + ECCONFIGURATION = 0, + EVENT, + CRITICALITY, + IMPORTANCE, + WORSTEXECUTION, + TYPICALEXECUTION, + TIMEOUT, + PERIOD, + PHASE, + LOCALEVENTCHANNEL, + REMOTEEVENTCHANNEL, + SCHEDULINGSTRATEGY, + CONSUMER, + SUBSCRIPTIONS, + EVENTNAME, + DEPENDANTS, + SUPPLIERNAME, + SUPPLIER, + PUBLICATIONS, + TRIGGERS, + TIMEOUTNAME, + IORFILE, + TESTDRIVER, + STARTCONDITION, + TIME, + STOPCONDITION, + VALUE, + UNKNOWN_ELEMENT + }; + + virtual ~VisitableSyntax (void) + {} + + virtual int visit (SyntaxVisitor* v, void* arg) = 0; + + virtual element getSyntaxType (void) + { + return UNKNOWN_ELEMENT; + } +}; + +class StringSyntax: public VisitableSyntax +{ +public: + + virtual ~StringSyntax (void) + {} + + // Value + ACE_CString str; +}; + +class IntegerSyntax: public VisitableSyntax +{ +public: + + virtual ~IntegerSyntax (void) + {} + + // Value + int val; +}; + +class Driver: public VisitableSyntax +{ +public: + + virtual ~Driver (void) + {} + +}; + +// Specific parse types + +class ECConfiguration : public VisitableSyntax +{ +public: + + virtual ~ECConfiguration (void) + {} + + virtual element getSyntaxType (void) + { + return ECCONFIGURATION; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseECConfiguration (this,arg); + } + + // Children + std::vector<Event*> events; + std::vector<Timeout*> timeouts; + std::vector<LocalEventChannel*> localECs; + std::vector<RemoteEventChannel*> remoteECs; + Driver *driver; +}; + +class Event : public VisitableSyntax +{ +public: + + virtual ~Event (void) + {} + + virtual element getSyntaxType (void) + { + return EVENT; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseEvent (this,arg); + } + + // Children + Period *period; + Phase *phase; + Criticality *criticality; + Importance *importance; + WorstExecution *worstexecution; + TypicalExecution *typicalexecution; + + // Attributes + ACE_CString name; +}; + +class Criticality : public VisitableSyntax +{ +public: + + virtual ~Criticality (void) + {} + + virtual element getSyntaxType (void) + { + return CRITICALITY; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseCriticality (this,arg); + } + + // Attributes + RtecScheduler::Criticality_t value; +}; + +class Importance : public VisitableSyntax +{ +public: + + virtual ~Importance (void) + {} + + virtual element getSyntaxType (void) + { + return IMPORTANCE; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseImportance (this,arg); + } + + // Attributes + RtecScheduler::Importance_t value; +}; + +class Timeout : public VisitableSyntax +{ +public: + + virtual ~Timeout (void) + {} + + virtual element getSyntaxType (void) + { + return TIMEOUT; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseTimeout (this,arg); + } + + // Children + Period *period; + Phase *phase; + + // Attributes + ACE_CString name; +}; + +class LocalEventChannel : public VisitableSyntax +{ +public: + + virtual ~LocalEventChannel (void) + {} + + virtual element getSyntaxType (void) + { + return LOCALEVENTCHANNEL; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseLocalEventChannel (this,arg); + } + + // Children + SchedulingStrategy *schedulingstrategy; + std::vector<Consumer*> consumers; + std::vector<Supplier*> suppliers; + + // Attributes + ACE_CString name; +}; + +class RemoteEventChannel : public VisitableSyntax +{ +public: + + virtual ~RemoteEventChannel (void) + {} + + virtual element getSyntaxType (void) + { + return REMOTEEVENTCHANNEL; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseRemoteEventChannel (this,arg); + } + + // Children + IORFile *iorfile; + std::vector<Consumer*> consumers; + std::vector<Supplier*> suppliers; + + // Attributes + ACE_CString name; +}; + +class SchedulingStrategy : public VisitableSyntax +{ +public: + + virtual ~SchedulingStrategy (void) + {} + + virtual element getSyntaxType (void) + { + return SCHEDULINGSTRATEGY; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseSchedulingStrategy (this,arg); + } + + // Attributes + enum { EDF, + MUF, + RMS } type; + bool enableRG;; +}; + +class Consumer : public VisitableSyntax +{ +public: + + virtual ~Consumer (void) + {} + + virtual element getSyntaxType (void) + { + return CONSUMER; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseConsumer (this,arg); + } + + // Children + Subscriptions *subscriptions; + Dependants *dependants; + + // Attributes + ACE_CString name; +}; + +class Subscriptions : public VisitableSyntax +{ +public: + + virtual ~Subscriptions (void) + {} + + virtual element getSyntaxType (void) + { + return SUBSCRIPTIONS; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseSubscriptions (this,arg); + } + + // Children + std::vector<EventName*> eventnames; +}; + +class Dependants : public VisitableSyntax +{ +public: + + virtual ~Dependants (void) + {} + + virtual element getSyntaxType (void) + { + return DEPENDANTS; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseDependants (this,arg); + } + + // Children + std::vector<SupplierName*> suppliernames; +}; + +class Supplier : public VisitableSyntax +{ +public: + + virtual ~Supplier (void) + {} + + virtual element getSyntaxType (void) + { + return SUPPLIER; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseSupplier (this,arg); + } + + // Children + Publications *publications; + Triggers *triggers; + + // Attributes + ACE_CString name; +}; + +class Publications : public VisitableSyntax +{ +public: + + virtual ~Publications (void) + {} + + virtual element getSyntaxType (void) + { + return PUBLICATIONS; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parsePublications (this,arg); + } + + // Children + std::vector<EventName*> eventnames; +}; + +class Triggers : public VisitableSyntax +{ +public: + + virtual ~Triggers (void) + {} + + virtual element getSyntaxType (void) + { + return TRIGGERS; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseTriggers (this,arg); + } + + // Children + std::vector<EventName*> eventnames; + std::vector<TimeoutName*> timeoutnames; +}; + +class TestDriver : public Driver +{ +public: + + virtual ~TestDriver (void) + {} + + virtual element getSyntaxType (void) + { + return TESTDRIVER; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseTestDriver (this,arg); + } + + // Children + StartCondition *startcondition; + StopCondition *stopcondition; +}; + +class StartCondition : public VisitableSyntax +{ +public: + + virtual ~StartCondition (void) + {} + + virtual element getSyntaxType (void) + { + return STARTCONDITION; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseStartCondition (this,arg); + } + + // Children + Time *time; + + // Attributes + enum { GLOBALTIME, + DELAYAFTERSTART, + DELAYAFTERCONNECT } type; + bool master; +}; + +class StopCondition : public VisitableSyntax +{ +public: + + virtual ~StopCondition (void) + {} + + virtual element getSyntaxType (void) + { + return STOPCONDITION; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseStopCondition (this,arg); + } + + // Children + Value *value; + + // Attributes + enum { DURATION, + EVENTNUMBER } type; +}; + +// String value elements + +class EventName : public StringSyntax +{ +public: + + virtual element getSyntaxType (void) + { + return EVENTNAME; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseEventName (this,arg); + } + +}; + +class SupplierName : public StringSyntax +{ +public: + + virtual element getSyntaxType (void) + { + return SUPPLIERNAME; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseSupplierName (this,arg); + } + +}; + +class TimeoutName : public StringSyntax +{ +public: + + virtual element getSyntaxType (void) + { + return TIMEOUTNAME; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseTimeoutName (this,arg); + } + +}; + +class IORFile : public StringSyntax +{ +public: + + virtual element getSyntaxType (void) + { + return IORFILE; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseIORFile (this,arg); + } + +}; + +// Integer value elements + +class WorstExecution : public IntegerSyntax +{ +public: + + virtual element getSyntaxType (void) + { + return WORSTEXECUTION; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseWorstExecution (this,arg); + } + +}; + +class TypicalExecution : public IntegerSyntax +{ +public: + + virtual element getSyntaxType (void) + { + return TYPICALEXECUTION; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseTypicalExecution (this,arg); + } + +}; + +class Period : public IntegerSyntax +{ +public: + + virtual element getSyntaxType (void) + { + return PERIOD; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parsePeriod (this,arg); + } + +}; + +class Phase : public IntegerSyntax +{ +public: + + virtual element getSyntaxType (void) + { + return PHASE; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parsePhase (this,arg); + } + +}; + +class Time : public IntegerSyntax +{ +public: + + virtual element getSyntaxType (void) + { + return TIME; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseTime (this,arg); + } + +}; + +class Value : public IntegerSyntax +{ +public: + + virtual element getSyntaxType (void) + { + return VALUE; + } + + virtual int visit(SyntaxVisitor* v, void* arg) + { + return v->parseValue (this,arg); + } + +}; + +const int MAXTYPESTRINGLEN = 32; + +//Copies as much of the type name to the buffer as fits; buf will null-term. +void visitableTypeToString (VisitableSyntax::element type, char *buf, int buflen); + +#endif //SYNTAXTREE_H diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxVisitor.h b/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxVisitor.h new file mode 100644 index 00000000000..a123511ea60 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxVisitor.h @@ -0,0 +1,115 @@ +// $Id$ + +//============================================================================= +/** + * @file SyntaxVisitor.h + * + * $Id$ + * + * @author Bryan Thrall <thrall@cse.wustl.edu> + */ +//============================================================================= + + +#ifndef SYNTAXVISITOR_H +#define SYNTAXVISITOR_H + +#include "ACEXML/common/SAXExceptions.h" + +// Forward declarations +class VisitableSyntax; +class ECConfiguration; +class Event; +class Criticality; +class Importance; +class Timeout; +class LocalEventChannel; +class RemoteEventChannel; +class SchedulingStrategy; +class Consumer; +class Subscriptions; +class Dependants; +class Supplier; +class Publications; +class Triggers; +class TestDriver; +class StartCondition; +class StopCondition; +class EventName; +class SupplierName; +class TimeoutName; +class IORFile; +class WorstExecution; +class TypicalExecution; +class Period; +class Phase; +class Time; +class Value; + +class SyntaxVisitor +{ +public: + virtual int parseVisitableSyntax (VisitableSyntax vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + + virtual int parseECConfiguration (ECConfiguration* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseEvent (Event* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseCriticality (Criticality* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseImportance (Importance* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseTimeout (Timeout* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseLocalEventChannel (LocalEventChannel* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseRemoteEventChannel (RemoteEventChannel* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseSchedulingStrategy (SchedulingStrategy* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseConsumer (Consumer* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseSubscriptions (Subscriptions* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseDependants (Dependants* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseSupplier (Supplier* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parsePublications (Publications* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseTriggers (Triggers* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseTestDriver (TestDriver* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseStartCondition (StartCondition* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseStopCondition (StopCondition* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + + virtual int parseEventName (EventName* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseSupplierName (SupplierName* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseTimeoutName (TimeoutName* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseIORFile (IORFile* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseWorstExecution (WorstExecution* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseTypicalExecution (TypicalExecution* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parsePeriod (Period* vs, void *arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parsePhase (Phase* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseTime (Time* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual int parseValue (Value* vs, void* arg) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + + virtual VisitableSyntax* getRootNode (void) = 0; + +}; + +#endif //SYNTAXVISITOR_H diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/clientconfig.xml b/TAO/orbsvcs/examples/RtEC/ECConfigurator/clientconfig.xml new file mode 100644 index 00000000000..c170e6b2ee0 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/clientconfig.xml @@ -0,0 +1,65 @@ +<?xml version="1.0"?> +<!DOCTYPE ECConfiguration SYSTEM "ecconfig.dtd"> + +<ECConfiguration> + +<!-- Define the events --> +<Timeout name="Subtask1.1 Timeout" > + <Period>200</Period> <!-- in msec --> + <Phase>0</Phase> <!-- in msec --> +</Timeout> + +<Event name="Subtask1.1 Trigger" > <!-- name must be unique among Events --> + <Period>200</Period> <!-- in msec --> + <Criticality value="VERY_LOW" /> + <Importance value="VERY_LOW" /> + <WorstExecution>50</WorstExecution> <!-- in msec --> + <TypicalExecution>50</TypicalExecution> <!-- in msec --> +</Event> + +<Event name="Subtask1.2 Trigger" > + <Period>200</Period> <!-- in msec --> + <Criticality value="VERY_LOW" /> + <Importance value="VERY_LOW" /> + <WorstExecution>50</WorstExecution> <!-- in msec --> + <TypicalExecution>50</TypicalExecution> <!-- in msec --> +</Event> + +<!-- Configure the ECs --> +<RemoteEventChannel name="Server" > + <IORFile>server.ior</IORFile> +</RemoteEventChannel> + +<LocalEventChannel name="Client" > + <SchedulingStrategy type="EDF" enableRG="true" /> + <Consumer name="Subtask1.1 Executor" > + <Subscriptions> + <EventName>Subtask1.1 Trigger</EventName> + </Subscriptions> + <Dependants> + <!-- no need for Supplier to be declared already --> + <SupplierName>Subtask1.2 Supplier</SupplierName> + </Dependants> + </Consumer> + <Supplier name="Subtask1.2 Supplier" > + <Publications> + <EventName>Subtask1.2 Trigger</EventName> + </Publications> + <Triggers> + <TimeoutName>Subtask1.1 Timeout</TimeoutName> + </Triggers> + </Supplier> +</LocalEventChannel> + +<!-- Configure the driver --> +<!-- there should only be one Driver --> +<TestDriver> + <StartCondition type="DelayAfterConnect" master="yes" > + <Time>30000</Time> <!-- in msecs --> + </StartCondition> + <StopCondition type="Duration" > + <Value>300000</Value> <!-- duration in msecs --> + </StopCondition> +</TestDriver> + +</ECConfiguration>
\ No newline at end of file diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ecconfig.dtd b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ecconfig.dtd new file mode 100644 index 00000000000..807b6718ab1 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ecconfig.dtd @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<!-- ECCONFIGURATION --> + <!ELEMENT ECConfiguration ((Event|Timeout)*,(LocalEventChannel|RemoteEventChannel)*,TestDriver) > + +<!-- EVENT --> + <!ELEMENT Event (Period,Phase,Criticality,Importance,WorstExecution,TypicalExecution) > + <!ATTLIST Event name CDATA #REQUIRED > + + <!ELEMENT Criticality (EMPTY) > + <!ATTLIST Criticality value (VERY_LOW|LOW|MEDIUM|HIGH|VERY_HIGH) #REQUIRED > + + <!ELEMENT Importance (EMPTY) > + <!ATTLIST Importance value (VERY_LOW|LOW|MEDIUM|HIGH|VERY_HIGH) #REQUIRED > + + <!ELEMENT WorstExecution (#PCDATA) > + + <!ELEMENT TypicalExecution (#PCDATA) > + +<!-- TIMEOUT --> + <!ELEMENT Timeout (Period,Phase?) > + <!ATTLIST Timeout name CDATA #REQUIRED > + + <!ELEMENT Period (#PCDATA) > + + <!ELEMENT Phase (#PCDATA) > + +<!-- LOCALEVENTCHANNEL --> + <!ELEMENT LocalEventChannel (SchedulingStrategy,(Consumer,Supplier)*) > + <!ATTLIST LocalEventChannel name CDATA #REQUIRED > + + <!ELEMENT SchedulingStrategy (EMPTY) > + <!ATTLIST SchedulingStrategy type (EDF|MUF|RMS) #REQUIRED > + <!ATTLIST SchedulingStrategy enableRG (yes|no) #REQUIRED > + + <!ELEMENT Consumer (Subscriptions,Dependants?) > + <!ATTLIST Consumer name CDATA #REQUIRED > + + <!ELEMENT Subscriptions (EventName*) > + + <!ELEMENT EventName (#PCDATA) > + + <!ELEMENT Dependants (SupplierName*) > + + <!ELEMENT SupplierName (#PCDATA) > + + <!-- If no Triggers is supplied (or it is empty), the Supplier is assumed to be self-triggered --> + <!ELEMENT Supplier (Publications,Triggers?) > + <!ATTLIST Supplier name CDATA #REQUIRED > + + <!ELEMENT Publications (EventName*) > + + <!ELEMENT Triggers ((EventName|TimeoutName)*) > + + <!ELEMENT TimeoutName (#PCDATA) > + +<!-- REMOTEEVENTCHANNEL --> + <!-- Consumer/Supplier on remote are local but subscribe/publish remotely --> + <!ELEMENT RemoteEventChannel (IORFile, (Consumer,Supplier)*) > + <!ATTLIST RemoteEventChannel name CDATA #REQUIRED > + + <!ELEMENT IORFile (#PCDATA) > + +<!-- There should only be one Driver for each process--> +<!-- TESTDRIVER --> + <!ELEMENT TestDriver (StartCondition,StopCondition) > + + <!ELEMENT StartCondition (Time) > + <!ATTLIST StartCondition type (GlobalTime|DelayAfterStart|DelayAfterConnect) #REQUIRED > + <!ATTLIST StartCondition master (yes|no) "no" > + + <!ELEMENT Time (#PCDATA) > + + <!ELEMENT StopCondition (Value) > + <!ATTLIST StopCondition type (Duration|EventNumber) #REQUIRED > + + <!ELEMENT Value (#PCDATA) > diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ecconfigurator.mpc b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ecconfigurator.mpc new file mode 100644 index 00000000000..71deb191b84 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ecconfigurator.mpc @@ -0,0 +1,15 @@ +project(configurable_ec): orbsvcsexe, rtevent, rtsched, rtschedevent, rtkokyuevent, kokyu, acexml { + exename = ConfigurableEC + libpaths += . + includes += $(TAO_ROOT)/orbsvcs $(TAO_ROOT)/orbsvcs/orbsvcs + + Source_Files { + Configurator_ParseHandler.cpp + Configurator_SyntaxHandler.cpp + SyntaxTree.cpp + ConfigurableEC.cpp + } + + IDL_Files { + } +} diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/serverconfig.xml b/TAO/orbsvcs/examples/RtEC/ECConfigurator/serverconfig.xml new file mode 100644 index 00000000000..7dcb310839a --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/serverconfig.xml @@ -0,0 +1,56 @@ +<?xml version="1.0"?> +<!DOCTYPE ECConfiguration SYSTEM "ecconfig.dtd"> + +<ECConfiguration> + +<!-- Define the events --> +<!-- THESE NEED TO BE THE SAME AS DEFINED IN THE CLIENT XML! --> +<Timeout name="Subtask1.1 Timeout" > + <Period>200</Period> <!-- in msec --> + <Phase>0</Phase> <!-- in msec --> +</Timeout> + +<Event name="Subtask1.1 Trigger" > <!-- name must be unique among Events --> + <Period>200</Period> <!-- in msec --> + <Criticality value="VERY_LOW" /> + <Importance value="VERY_LOW" /> + <WorstExecution>50</WorstExecution> <!-- in msec --> + <TypicalExecution>50</TypicalExecution> <!-- in msec --> +</Event> + +<Event name="Subtask1.2 Trigger" > + <Period>200</Period> <!-- in msec --> + <Criticality value="VERY_LOW" /> + <Importance value="VERY_LOW" /> + <WorstExecution>50</WorstExecution> <!-- in msec --> + <TypicalExecution>50</TypicalExecution> <!-- in msec --> +</Event> + +<!-- Configure the ECs --> +<RemoteEventChannel name="Client" > + <IORFile>client.ior</IORFile> +</RemoteEventChannel> + +<LocalEventChannel name="Server" > + <SchedulingStrategy type="EDF" enableRG="true" /> + <Consumer name="Subtask1.2 Executor" > + <Subscriptions> + <EventName>Subtask1.2 Trigger</EventName> + </Subscriptions> + <Dependants> + <!-- No dependents --> + </Dependants> + </Consumer> +</LocalEventChannel> + +<!-- Configure the driver --> +<TestDriver> + <StartCondition type="DelayAfterConnect" > + <Time>30000</Time> <!-- in msecs --> + </StartCondition> + <StopCondition type="Duration" > + <Value>300000</Value> <!-- duration in msecs --> + </StopCondition> +</TestDriver> + +</ECConfiguration>
\ No newline at end of file diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/svc.conf b/TAO/orbsvcs/examples/RtEC/ECConfigurator/svc.conf new file mode 100644 index 00000000000..ae8708fded9 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/svc.conf @@ -0,0 +1,4 @@ +# $Id$ +static EC_Factory "-ECProxyPushConsumerCollection mt:immediate:list -ECProxyPushSupplierCollection mt:immediate:list -ECdispatching kokyu -ECscheduling kokyu -ECfiltering kokyu -ECproxyconsumerlock thread -ECproxysupplierlock thread -ECsupplierfiltering per-supplier -ECObserver basic" +static Config_Factory "-ECConfig edf" +static EC_Gateway_IIOP_Factory "-ECGIIOPConsumerECControl reactive -ECGIIOPUseConsumerProxyMap 0"
\ No newline at end of file diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/svc.conf.xml b/TAO/orbsvcs/examples/RtEC/ECConfigurator/svc.conf.xml new file mode 100644 index 00000000000..00e4eb38f91 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/svc.conf.xml @@ -0,0 +1,8 @@ +<?xml version='1.0'?> +<!-- Converted from svc.conf by svcconf-convert.pl --> +<ACE_Svc_Conf> + <!-- $Id$ --> + <static id="EC_Factory" params="-ECProxyPushConsumerCollection mt:immediate:list -ECProxyPushSupplierCollection mt:immediate:list -ECdispatching kokyu -ECscheduling kokyu -ECfiltering kokyu -ECproxyconsumerlock thread -ECproxysupplierlock thread -ECsupplierfiltering per-supplier -ECObserver basic"/> + <static id="Config_Factory" params="-ECConfig edf"/> + <static id="EC_Gateway_IIOP_Factory" params="-ECGIIOPConsumerECControl reactive -ECGIIOPUseConsumerProxyMap 0"/> +</ACE_Svc_Conf> |