Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support to QOS_XML_Handler to parse a string #2439

Merged
merged 27 commits into from Jul 9, 2021

Conversation

dczanella
Copy link
Contributor

Hi there,

I changed/added some files to include a new functionality by module QOS_XML_Handler to parse not only files, but sequence of characters. This code requires xerces-c library to compile as well QOS_XML_Handler. I tested using xerces-c version 3.2.2.
This code should be ported to OpenDDS version 3.13.3.
Cheers

@@ -4,6 +4,7 @@
*
*
* @author Marcel Smit (msmit@remedy.nl)
* @2nd author Danilo C. Zanella (dczanella@gmail.com)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use @author, @2nd is not a valid doxygten tag

@@ -29,7 +31,8 @@ OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
namespace OpenDDS {
namespace DCPS {

class OpenDDS_XML_QOS_Handler_Export QOS_XML_File_Handler
class OpenDDS_XML_QOS_Handler_Export QOS_XML_File_Handler :
virtual public QOS_XML_Handler
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need to be virtual?


DDS::ReturnCode_t
QOS_XML_Handler::get_datareader_qos(::DDS::DataReaderQos& dr_qos,
const ACE_TCHAR * profile_name,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct indentation of the arguments, all functions

@@ -0,0 +1,228 @@

#include "XML_MemBuf_Intf.h"
//#include "ace/XML_Utils/XML_Typedefs.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented out includes

QOS_XML_Handler(),
res_(new XML::XML_Schema_Resolver<XML::Environment_Resolver>()),
eh_(new XML::XML_Error_Handler())
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialise parser_ with 0


//// Check for errors
//if (eh_->getErrors())
//{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented out code

if (DCPS_debug_level > 1)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("QOS_XML_Stream_Handler::init - ")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong classname

catch (...)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("QOS_XML_Stream_Handler::init - ")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong class name, check all messages

try
{
// File name and profile name in respective file
const char * fileName = "qos.xml";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use ACE_TCHAR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it.

#include "XML_Intf.h"
#include "dds/DdsDcpsInfrastructureC.h"
#include "OpenDDS_XML_QOS_Handler_Export.h"
#include "ace/XML_Utils/XML_Typedefs.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer to extend the forward declared classes below and don't inlcude XM_Utils in the header, let us now expose any internals to the user

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I did it.

@dczanella
Copy link
Contributor Author

Hi,

I need some help to complete the task. Some checks were not successful and it is not clear for me.
Thank


DDS::ReturnCode_t
QOS_XML_Handler::get_datawriter_qos(::DDS::DataWriterQos& dw_qos,
const ACE_TCHAR * profile_name,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation strange

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi
Could you be more specific?
Thanks

ACE_TEXT ("Exception message is: <%C>\n"),
message));
XMLString::release(&message);
return DDS::RETCODE_ERROR;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of a failure you don't disable ACE::debug

XMLString::release(&message);
}

DOMNode * clone = finalDoc_->importNode(ddsNode, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can clone become 0?


exit 0;

#eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented out code

Comment on lines 64 to 66
QOS_XML_Handler::get_datawriter_qos(::DDS::DataWriterQos& dw_qos,
const ACE_TCHAR * profile_name,
const ACE_TCHAR * topic_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
QOS_XML_Handler::get_datawriter_qos(::DDS::DataWriterQos& dw_qos,
const ACE_TCHAR * profile_name,
const ACE_TCHAR * topic_name)
QOS_XML_Handler::get_datawriter_qos(::DDS::DataWriterQos& dw_qos,
const ACE_TCHAR * profile_name,
const ACE_TCHAR * topic_name)

if (DCPS_debug_level > 1)
{
char* message = XMLString::transcode(ddsNode->getNodeName());
ACE_ERROR ((LM_INFO,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be ACE_DEBUG for a debug message

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi
I'll do it, but in QOS_XML_Loader.cpp it uses as I did.
Check following code:

DDS::ReturnCode_t
QOS_XML_Loader::init(const ACE_TCHAR* qos_profile)
{
if (!qos_profile)
{
if (DCPS_debug_level > 5)
{
ACE_ERROR((LM_ERROR,
ACE_TEXT("QOS_XML_Loader::init - ")
ACE_TEXT("Passed an empty qos_profile, returning.\n")));
}

Cheers

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACE_ERROR is for logging error messages, ACE_DEBUG for debug/info messages, both could be independently enabled/disabled at compilation time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another question is:
How can i set the DCPS_debug_level variable? I set grater than 1, but is there some policy to do that?
Cheers

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this is an error you should use LM_ERROR instead of LM_INFO

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another question is:
How can i set the DCPS_debug_level variable? I set grater than 1, but is there some policy to do that?
Cheers

See http://download.objectcomputing.com/OpenDDS/OpenDDS-latest.pdf, chapter 7.6.1

if (ACE_OS::strcmp((*it)->name().c_str(), profileName) == 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) DEBUG: QOS_XML_Handler::addQoSProfile - ")
ACE_TEXT("Profile exists or profile name in use.\n")));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log profile name

@dczanella
Copy link
Contributor Author

dczanella commented May 10, 2021 via email

@dczanella dczanella requested a review from jwillemsen May 11, 2021 23:58
Copy link
Member

@jwillemsen jwillemsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments, in general looks ok

++it)
{
if (ACE_OS::strcmp((*it)->name().c_str(), profileName) == 0) {
ACE_DEBUG((LM_DEBUG,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an error

}
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) ERROR: QOS_XML_Handler::delQoSProfile - ")
ACE_TEXT("Profile doesn't exists or wrong profile name.\n")));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error?

{
if (DCPS_debug_level > 1)
{
ACE_DEBUG ((LM_DEBUG,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error?

if (ACE_OS::strcmp((*it)->name().c_str(), profileName) == 0) {
if (DCPS_debug_level > 7)
{
ACE_DEBUG((LM_DEBUG,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ACE_DEBUG((LM_DEBUG,
ACE_ERROR((LM_ERROR,

DDS::ReturnCode_t
QOS_XML_Handler::addQoSProfileSeq(const dds::qosProfile_seq & profiles)
{

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty lines at the top and bottom of this operation


if (ACE_OS::strlen(profileName) == 0)
{
ACE_ERROR((LM_ERROR,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check debug level here for logging

{
if (DCPS_debug_level > 1)
{
ACE_DEBUG ((LM_DEBUG,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ACE_DEBUG ((LM_DEBUG,
ACE_ERROR ((LM_ERROR,

@dczanella dczanella requested a review from jwillemsen May 25, 2021 13:49
Copy link
Member

@mitza-oci mitza-oci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is confusing to me that this feature is for a "memory buffer." In terms the standard library uses this would be a "string," for example stringstream vs. fstream. The public API seems to be the init(const char*) method.

@dczanella
Copy link
Contributor Author

dczanella commented May 25, 2021 via email

@mitza-oci
Copy link
Member

I didn't catch that. What is your question? The idea is to manipulate xml from a sequence of chars besides a file.

I think it would be more clear for users if the new class was called something like QOS_XML_String_Handler to go with QOS_XML_File_Handler just like std::stringstream goes with std::fstream.

@dczanella
Copy link
Contributor Author

dczanella commented May 25, 2021 via email

@dczanella
Copy link
Contributor Author

dczanella commented May 25, 2021 via email

@mitza-oci
Copy link
Member

Check if there are more changes needed. Thus I do it once. Cheers

I think this should be a straightforward renaming. A side effect of doing another push to the branch is that it will re-run CI testing with the latest updates to how we've set up GitHub Actions.

@dczanella dczanella requested a review from mitza-oci July 1, 2021 19:30
tests/dcps_tests.lst Outdated Show resolved Hide resolved
@dczanella
Copy link
Contributor Author

dczanella commented Jul 8, 2021 via email

@mitza-oci
Copy link
Member

CI checks are currently running on this pull request. Please take a look when those are done running and address any issues related to changes from this PR. There is already one failure in the "lint" check.

@mitza-oci mitza-oci changed the title Added support to QOS_XML_Handler to parse a memory buffer Added support to QOS_XML_Handler to parse a string Jul 9, 2021
@mitza-oci mitza-oci merged commit 003261f into OpenDDS:master Jul 9, 2021
@jwillemsen
Copy link
Member

Hi That is good news. Thanks Adam and Johnny, I have learned a lot with you. I would like to continue contributing with the project. I solved this small issue that was related to my job. If there are more things that I could help I'm wondering. Cheers

Maybe #2434, also in the QoS code, some new QoS settings can't be done through XML

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants