00001 #include "ConnectionSettings.h"
00002
00003 #include "ace/OS_NS_stdio.h"
00004 #include "ace/Log_Priority.h"
00005 #include "ace/Log_Msg.h"
00006
00007 #include <cstring>
00008
00009 namespace OpenDDS { namespace FaceTSS { namespace config {
00010
00011 ConnectionSettings::ConnectionSettings()
00012 : connection_id_(0),
00013 direction_(FACE::SOURCE),
00014 domain_id_(0),
00015 participant_id_(0)
00016 {
00017 std::strcpy(topic_name_, "");
00018 std::strcpy(datawriter_qos_name_, "");
00019 std::strcpy(datareader_qos_name_, "");
00020 std::strcpy(publisher_qos_name_, "");
00021 std::strcpy(subscriber_qos_name_, "");
00022 std::strcpy(config_name_, "");
00023 }
00024
00025 int
00026 ConnectionSettings::set(const char* name, const char* value)
00027 {
00028 int status = 0;
00029 if (!std::strcmp(name, "id")) {
00030 connection_id_ = atoi(value);
00031 } else if (!std::strcmp(name, "participantid")) {
00032 participant_id_ = atoi(value);
00033 } else if (!std::strcmp(name, "domain")) {
00034 domain_id_ = atoi(value);
00035 } else if (!std::strcmp(name, "topic")) {
00036 std::strncpy(topic_name_, value, sizeof(topic_name_));
00037 } else if (!std::strcmp(name, "datawriterqos")) {
00038 std::strncpy(datawriter_qos_name_, value, sizeof(datawriter_qos_name_));
00039 } else if (!std::strcmp(name, "datareaderqos")) {
00040 std::strncpy(datareader_qos_name_, value, sizeof(datareader_qos_name_));
00041 } else if (!std::strcmp(name, "publisherqos")) {
00042 std::strncpy(publisher_qos_name_, value, sizeof(publisher_qos_name_));
00043 } else if (!std::strcmp(name, "subscriberqos")) {
00044 std::strncpy(subscriber_qos_name_, value, sizeof(subscriber_qos_name_));
00045 } else if (!std::strcmp(name, "direction")) {
00046 if (!std::strcmp(value, "source") ||
00047 !std::strcmp(value, "one_way_request_source") ||
00048 !std::strcmp(value, "two_way_request_synchronous_source") ||
00049 !std::strcmp(value, "two_way_request_reply_asynchronous_source")) {
00050 direction_ = FACE::SOURCE;
00051 } else if (!std::strcmp(value, "destination") ||
00052 !std::strcmp(value, "one_way_request_destination") ||
00053 !std::strcmp(value, "two_way_request_synchronous_destination") ||
00054 !std::strcmp(value, "two_way_request_reply_asynchronous_destination")) {
00055 direction_ = FACE::DESTINATION;
00056 } else if (!std::strcmp(value, "bi_directional") ||
00057 !std::strcmp(value, "not_defined_connection_direction_type")) {
00058 ACE_ERROR((LM_ERROR, ACE_TEXT("Direction not supported: %C\n"), value));
00059 status = 1;
00060 } else {
00061 ACE_ERROR((LM_ERROR, ACE_TEXT("Don't know of direction %C\n"), value));
00062 status = 1;
00063 }
00064 } else if (!std::strcmp(name, "config")) {
00065 std::strncpy(config_name_, value, sizeof(config_name_));
00066 } else {
00067
00068 ACE_ERROR((LM_ERROR, ACE_TEXT("Don't know of setting %C\n"), name));
00069 status = 1;
00070 }
00071
00072 return status;
00073 }
00074
00075 const char*
00076 ConnectionSettings::datawriter_qos_name() const
00077 {
00078 return datawriter_qos_name_;
00079 }
00080
00081 const char*
00082 ConnectionSettings::datareader_qos_name() const
00083 {
00084 return datareader_qos_name_;
00085 }
00086
00087 const char*
00088 ConnectionSettings::publisher_qos_name() const
00089 {
00090 return publisher_qos_name_;
00091 }
00092
00093 const char*
00094 ConnectionSettings::subscriber_qos_name() const
00095 {
00096 return subscriber_qos_name_;
00097 }
00098
00099 const char*
00100 ConnectionSettings::config_name() const
00101 {
00102 return config_name_;
00103 }
00104
00105 bool
00106 ConnectionSettings::datawriter_qos_set() const
00107 {
00108 return datawriter_qos_name_[0];
00109 }
00110
00111 bool
00112 ConnectionSettings::datareader_qos_set() const
00113 {
00114 return datareader_qos_name_[0];
00115 }
00116
00117 bool
00118 ConnectionSettings::publisher_qos_set() const
00119 {
00120 return publisher_qos_name_[0];
00121 }
00122
00123 bool
00124 ConnectionSettings::subscriber_qos_set() const
00125 {
00126 return subscriber_qos_name_[0];
00127 }
00128
00129 bool
00130 ConnectionSettings::config_set() const
00131 {
00132 return config_name_[0];
00133 }
00134
00135 } } }