From 5e4143a401129d0025391cfac7a9e7b2434a73e7 Mon Sep 17 00:00:00 2001 From: nanbor Date: Tue, 12 Feb 2002 07:18:23 +0000 Subject: Intermediate stuff --- ACEXML/examples/svcconf/Svcconf_Handler.cpp | 161 ++++++++++++++++++++++++++-- ACEXML/examples/svcconf/Svcconf_Handler.h | 31 ++++++ ACEXML/examples/svcconf/Svcconf_Handler.i | 14 +++ 3 files changed, 195 insertions(+), 11 deletions(-) diff --git a/ACEXML/examples/svcconf/Svcconf_Handler.cpp b/ACEXML/examples/svcconf/Svcconf_Handler.cpp index 18307539f25..279cc4ae978 100644 --- a/ACEXML/examples/svcconf/Svcconf_Handler.cpp +++ b/ACEXML/examples/svcconf/Svcconf_Handler.cpp @@ -109,50 +109,50 @@ ACEXML_Svcconf_Handler::startElement (const ACEXML_Char *, { if (ACE_OS_String::strcmp (qName, "dynamic") == 0) { - + this->get_dynamic_attrs (alist, xmlenv); } else if (ACE_OS_String::strcmp (qName, "initializer") == 0) { - + this->get_initializer_attrs (alist, xmlenv); } else if (ACE_OS_String::strcmp (qName, "static") == 0) { - + this->get_static_attrs (alist, xmlenv); } else if (ACE_OS_String::strcmp (qName, "stream") == 0) { this->get_stream_id (alist, xmlenv); - // @@ retrieve stream from Service_Repository here. - return; + // @@ retrieve stream service object from Service_Repository here. } else if (ACE_OS_String::strcmp (qName, "streamdef") == 0) { this->in_stream_def_ = 1; this->get_stream_id (alist, xmlenv); - return; + // @@ Set up stream service object } else if (ACE_OS_String::strcmp (qName, "module") == 0) { this->in_module_ = 1; - } else if (ACE_OS_String::strcmp (qName, "resume") == 0) { - + this->get_id (alist, xmlenv); } else if (ACE_OS_String::strcmp (qName, "suspend") == 0) { - + this->get_id (alist, xmlenv); } else if (ACE_OS_String::strcmp (qName, "remove") == 0) { - + this->get_id (alist, xmlenv); } else { - + // @@ Error. Perhaps we should relay to user event handler here, if available. } + return; + if (alist != 0) for (size_t i = 0; i < alist->getLength (); ++i) { @@ -255,3 +255,142 @@ ACEXML_Svcconf_Handler::get_stream_id (ACEXML_Attributes *alist, } return 0; } + +int +ACEXML_Svcconf_Handler::get_id (ACEXML_Attributes *alist, + ACEXML_Env &xmlenv) +{ + if (alist != 0) + for (size_t i = 0; i < alist->getLength (); ++i) + { + if (ACE_OS_String::strcmp (alist->getQName (i), "id") == 0) + { + this->parsed_info_.name (alist->getValue (i)); + } + else + { + // @@ Exception... + return -1; + } + } + return 0; +} + +int +ACEXML_Svcconf_Handler::get_dynamic_attrs (ACEXML_Attributes *alist, + ACEXML_Env &xmlenv) +{ + if (alist != 0) + { + ACE_Parsed_Info &info = (this->in_stream_def_ == 0 ? + this->parsed_info_ : + this->stream_info_); + for (size_t i = 0; i < alist->getLength (); ++i) + { + if (ACE_OS_String::strcmp (alist->getQName (i), "id") == 0) + { + info.name (alist->getValue (i)); + } + else if (ACE_OS_String::strcmp (alist->getQName (i), "status") == 0) + { + if (ACE_OS_String::strcmp (alist->getValue (i), "inactive") == 0) + { + } + else if (ACE_OS_String::strcmp (alist->getValue (i), "active") == 0) + { + } + else + { + // @@ error, invalid 'status' value. + } + } + else if (ACE_OS_String::strcmp (alist->getQName (i), "type") == 0) + { + if (ACE_OS_String::strcmp (alist->getValue (i), "service_object") == 0) + { + info.service_type (ACE_Parsed_Info::SERVICE_OBJECT_TYPE); + } + else if (ACE_OS_String::strcmp (alist->getValue (i), "stream") == 0) + { + info.service_type (ACE_Parsed_Info::STREAM_TYPE); + } + else if (ACE_OS_String::strcmp (alist->getValue (i), "module") == 0) + { + info.service_type (ACE_Parsed_Info::MODULE_TYPE); + } + else + { + // @@ error, invalid 'type' value. + } + } + else + { + // @@ Exception... + return -1; + } + } + } + return 0; +} + +int +ACEXML_Svcconf_Handler::get_initializer_attrs (ACEXML_Attributes *alist, + ACEXML_Env &xmlenv) +{ + if (alist != 0) + { + ACE_Parsed_Info &info = (this->in_stream_def_ == 0 ? + this->parsed_info_ : + this->stream_info_); + for (size_t i = 0; i < alist->getLength (); ++i) + { + if (ACE_OS_String::strcmp (alist->getQName (i), "init") == 0) + { + info.init_func (alist->getValue (i)); + } + else if (ACE_OS_String::strcmp (alist->getQName (i), "path") == 0) + { + info.path (alist->getValue (i)); + } + else if (ACE_OS_String::strcmp (alist->getQName (i), "params") == 0) + { + info.init_params (alist->getValue (i)); + } + else + { + // @@ Exception... + return -1; + } + } + } + return 0; +} + +int +ACEXML_Svcconf_Handler::get_static_attrs (ACEXML_Attributes *alist, + ACEXML_Env &xmlenv) +{ + if (alist != 0) + { + ACE_Parsed_Info &info = (this->in_stream_def_ == 0 ? + this->parsed_info_ : + this->stream_info_); + for (size_t i = 0; i < alist->getLength (); ++i) + { + if (ACE_OS_String::strcmp (alist->getQName (i), "id") == 0) + { + info.name (alist->getValue (i)); + } + else if (ACE_OS_String::strcmp (alist->getQName (i), "params") == 0) + { + info.init_params (alist->getValue (i)); + } + else + { + // @@ Exception... + return -1; + } + } + } + return 0; +} diff --git a/ACEXML/examples/svcconf/Svcconf_Handler.h b/ACEXML/examples/svcconf/Svcconf_Handler.h index 080a800eec8..4f9a52feae8 100644 --- a/ACEXML/examples/svcconf/Svcconf_Handler.h +++ b/ACEXML/examples/svcconf/Svcconf_Handler.h @@ -40,6 +40,12 @@ public: int service_type (Service_Type type); Service_Type service_type (void); + /** + * Set/Get active status. + */ + int active (int a); + int active (void); + /** * Set/get initializer path. */ @@ -66,6 +72,7 @@ public: protected: ACEXML_Char *name_; Service_Type service_type_; + int active_; ACEXML_Char *path_; ACEXML_Char *init_func_; ACEXML_Char *init_params_; @@ -277,6 +284,30 @@ protected: int get_stream_id (ACEXML_Attributes *alist, ACEXML_Env &xmlenv); + /** + * Get the only attribute in , , + */ + int get_id (ACEXML_Attributes *alist, + ACEXML_Env &xmlenv); + + /** + * Get the dynamic tag attributes. + */ + int get_dynamic_attrs (ACEXML_Attributes *alist, + ACEXML_Env &xmlenv); + + /** + * Get the initializer tag attributes. + */ + int get_initializer_attrs (ACEXML_Attributes *alist, + ACEXML_Env &xmlenv); + + /** + * Get the static tag attributes. + */ + int get_static_attrs (ACEXML_Attributes *alist, + ACEXML_Env &xmlenv); + private: /// We are parsing a stream definition int in_stream_def_; diff --git a/ACEXML/examples/svcconf/Svcconf_Handler.i b/ACEXML/examples/svcconf/Svcconf_Handler.i index 48038ddf93a..637778485a4 100644 --- a/ACEXML/examples/svcconf/Svcconf_Handler.i +++ b/ACEXML/examples/svcconf/Svcconf_Handler.i @@ -4,6 +4,7 @@ ACE_INLINE ACE_Parsed_Info::ACE_Parsed_Info () : name_ (0), service_type_ (INVALID_TYPE), + active_ (1), path_ (0), init_func_ (0), init_params_ (0) @@ -53,6 +54,19 @@ ACE_Parsed_Info::service_type (void) return this->service_type_; } +ACE_INLINE int +ACE_Parsed_Info::active (int a) +{ + this->active_ = a; + return 0; +} + +ACE_INLINE int +ACE_Parsed_Info::active (void) +{ + return this->active_; +} + ACE_INLINE int ACE_Parsed_Info::path (const ACEXML_Char *p) { -- cgit v1.2.1