From f6beada3cb3de32f273629d33ded35823e69c39e Mon Sep 17 00:00:00 2001 From: Josh Pelkey Date: Fri, 13 May 2011 14:51:51 -0400 Subject: [PATCH] config-store coding style changes --- src/config-store/model/config-store.cc | 68 +++--- src/config-store/model/display-functions.cc | 2 +- src/config-store/model/display-functions.h | 2 +- src/config-store/model/file-config.cc | 11 +- src/config-store/model/model-node-creator.cc | 8 +- .../model/model-typeid-creator.cc | 2 +- src/config-store/model/raw-text-config.cc | 32 +-- src/config-store/model/xml-config.cc | 230 +++++++++--------- 8 files changed, 180 insertions(+), 175 deletions(-) diff --git a/src/config-store/model/config-store.cc b/src/config-store/model/config-store.cc index 3c47b217f..de0d6e020 100644 --- a/src/config-store/model/config-store.cc +++ b/src/config-store/model/config-store.cc @@ -30,24 +30,24 @@ ConfigStore::GetTypeId (void) static TypeId tid = TypeId ("ns3::ConfigStore") .SetParent () .AddAttribute ("Mode", - "Configuration mode", - EnumValue (ConfigStore::NONE), - MakeEnumAccessor (&ConfigStore::SetMode), - MakeEnumChecker (ConfigStore::NONE, "None", - ConfigStore::LOAD, "Load", - ConfigStore::SAVE, "Save")) + "Configuration mode", + EnumValue (ConfigStore::NONE), + MakeEnumAccessor (&ConfigStore::SetMode), + MakeEnumChecker (ConfigStore::NONE, "None", + ConfigStore::LOAD, "Load", + ConfigStore::SAVE, "Save")) .AddAttribute ("Filename", - "The file where the configuration should be saved to or loaded from.", - StringValue (""), - MakeStringAccessor (&ConfigStore::SetFilename), - MakeStringChecker ()) + "The file where the configuration should be saved to or loaded from.", + StringValue (""), + MakeStringAccessor (&ConfigStore::SetFilename), + MakeStringChecker ()) .AddAttribute ("FileFormat", - "Type of file format", - EnumValue (ConfigStore::RAW_TEXT), - MakeEnumAccessor (&ConfigStore::SetFileFormat), - MakeEnumChecker (ConfigStore::RAW_TEXT, "RawText", - ConfigStore::XML, "Xml")) - ; + "Type of file format", + EnumValue (ConfigStore::RAW_TEXT), + MakeEnumAccessor (&ConfigStore::SetFileFormat), + MakeEnumChecker (ConfigStore::RAW_TEXT, "RawText", + ConfigStore::XML, "Xml")) + ; return tid; } TypeId @@ -65,34 +65,34 @@ ConfigStore::ConfigStore () if (m_fileFormat == ConfigStore::XML) { if (m_mode == ConfigStore::SAVE) - { - m_file = new XmlConfigSave (); - } + { + m_file = new XmlConfigSave (); + } else if (m_mode == ConfigStore::LOAD) - { - m_file = new XmlConfigLoad (); - } + { + m_file = new XmlConfigLoad (); + } else - { - m_file = new NoneFileConfig (); - } + { + m_file = new NoneFileConfig (); + } } else #endif /* HAVE_LIBXML2 */ if (m_fileFormat == ConfigStore::RAW_TEXT) { if (m_mode == ConfigStore::SAVE) - { - m_file = new RawTextConfigSave (); - } + { + m_file = new RawTextConfigSave (); + } else if (m_mode == ConfigStore::LOAD) - { - m_file = new RawTextConfigLoad (); - } + { + m_file = new RawTextConfigLoad (); + } else - { - m_file = new NoneFileConfig (); - } + { + m_file = new NoneFileConfig (); + } } m_file->SetFilename (m_filename); } diff --git a/src/config-store/model/display-functions.cc b/src/config-store/model/display-functions.cc index 0a1051125..b6943de20 100644 --- a/src/config-store/model/display-functions.cc +++ b/src/config-store/model/display-functions.cc @@ -590,5 +590,5 @@ clean_model_callback_config_default (GtkTreeModel *model, GtkTreePath *path, } -}//end ns3 namespace +} //end ns3 namespace diff --git a/src/config-store/model/display-functions.h b/src/config-store/model/display-functions.h index bb89f6b8a..41d1c260b 100644 --- a/src/config-store/model/display-functions.h +++ b/src/config-store/model/display-functions.h @@ -145,6 +145,6 @@ create_view_config_default (GtkTreeStore *model); gboolean clean_model_callback_config_default (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data); -}//end namespace ns3 +} //end namespace ns3 #endif diff --git a/src/config-store/model/file-config.cc b/src/config-store/model/file-config.cc index 64d43d60d..dc6547739 100644 --- a/src/config-store/model/file-config.cc +++ b/src/config-store/model/file-config.cc @@ -3,12 +3,15 @@ namespace ns3 { FileConfig::~FileConfig () -{} +{ +} NoneFileConfig::NoneFileConfig () -{} +{ +} NoneFileConfig::~NoneFileConfig () -{} +{ +} void NoneFileConfig::SetFilename (std::string filename) {} @@ -18,7 +21,7 @@ NoneFileConfig::Default (void) void NoneFileConfig::Global (void) {} -void +void NoneFileConfig::Attributes (void) {} diff --git a/src/config-store/model/model-node-creator.cc b/src/config-store/model/model-node-creator.cc index 0b5a3d245..c28e2031c 100644 --- a/src/config-store/model/model-node-creator.cc +++ b/src/config-store/model/model-node-creator.cc @@ -116,8 +116,8 @@ ModelCreator::DoStartVisitArrayItem (const ObjectVectorValue &vector, uint32_t i node->index = index; gtk_tree_store_append (m_treestore, current, parent); gtk_tree_store_set (m_treestore, current, - COL_NODE, node, - -1); + COL_NODE, node, + -1); m_iters.push_back (current); } void @@ -125,6 +125,6 @@ ModelCreator::DoEndVisitArrayItem (void) { GtkTreeIter *iter = m_iters.back (); g_free (iter); - m_iters.pop_back (); + m_iters.pop_back (); } -}//end namespace ns3 +} //end namespace ns3 diff --git a/src/config-store/model/model-typeid-creator.cc b/src/config-store/model/model-typeid-creator.cc index e6a2478ca..84e892024 100644 --- a/src/config-store/model/model-typeid-creator.cc +++ b/src/config-store/model/model-typeid-creator.cc @@ -78,4 +78,4 @@ ModelTypeidCreator::EndVisitTypeId (void) { Remove (); } -}//end namespace ns3 +} //end namespace ns3 diff --git a/src/config-store/model/raw-text-config.cc b/src/config-store/model/raw-text-config.cc index b83c95fef..5c0109699 100644 --- a/src/config-store/model/raw-text-config.cc +++ b/src/config-store/model/raw-text-config.cc @@ -12,7 +12,8 @@ namespace ns3 { RawTextConfigSave::RawTextConfigSave () : m_os (0) -{} +{ +} RawTextConfigSave::~RawTextConfigSave () { if (m_os != 0) @@ -33,11 +34,11 @@ RawTextConfigSave::Default (void) { class RawTextDefaultIterator : public AttributeDefaultIterator { - public: +public: RawTextDefaultIterator (std::ostream *os) { m_os = os; } - private: +private: virtual void StartVisitTypeId (std::string name) { m_typeId = name; } @@ -66,10 +67,10 @@ RawTextConfigSave::Attributes (void) { class RawTextAttributeIterator : public AttributeIterator { - public: +public: RawTextAttributeIterator (std::ostream *os) : m_os (os) {} - private: +private: virtual void DoVisitAttribute (Ptr object, std::string name) { StringValue str; object->GetAttribute (name, str); @@ -84,7 +85,8 @@ RawTextConfigSave::Attributes (void) RawTextConfigLoad::RawTextConfigLoad () : m_is (0) -{} +{ +} RawTextConfigLoad::~RawTextConfigLoad () { if (m_is != 0) @@ -121,9 +123,9 @@ RawTextConfigLoad::Default (void) NS_LOG_DEBUG ("type=" << type << ", name=" << name << ", value=" << value); value = Strip (value); if (type == "default") - { - Config::SetDefault (name, StringValue (value)); - } + { + Config::SetDefault (name, StringValue (value)); + } *m_is >> type >> name >> value; } } @@ -138,9 +140,9 @@ RawTextConfigLoad::Global (void) NS_LOG_DEBUG ("type=" << type << ", name=" << name << ", value=" << value); value = Strip (value); if (type == "global") - { - Config::SetGlobal (name, StringValue (value)); - } + { + Config::SetGlobal (name, StringValue (value)); + } *m_is >> type >> name >> value; } } @@ -155,9 +157,9 @@ RawTextConfigLoad::Attributes (void) NS_LOG_DEBUG ("type=" << type << ", path=" << path << ", value=" << value); value = Strip (value); if (type == "value") - { - Config::Set (path, StringValue (value)); - } + { + Config::Set (path, StringValue (value)); + } *m_is >> type >> path >> value; } } diff --git a/src/config-store/model/xml-config.cc b/src/config-store/model/xml-config.cc index 5551c909b..833fc0d86 100644 --- a/src/config-store/model/xml-config.cc +++ b/src/config-store/model/xml-config.cc @@ -82,39 +82,39 @@ XmlConfigSave::Default (void) { class XmlDefaultIterator : public AttributeDefaultIterator { - public: +public: XmlDefaultIterator (xmlTextWriterPtr writer) { m_writer = writer; } - private: +private: virtual void StartVisitTypeId (std::string name) { m_typeid = name; } virtual void DoVisitAttribute (std::string name, std::string defaultValue) { int rc; rc = xmlTextWriterStartElement(m_writer, BAD_CAST "default"); - if (rc < 0) - { - NS_FATAL_ERROR ("Error at xmlTextWriterStartElement"); - } - std::string fullname = m_typeid + "::" + name; - rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "name", - BAD_CAST fullname.c_str ()); - if (rc < 0) - { - NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); - } - rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "value", - BAD_CAST defaultValue.c_str ()); - if (rc < 0) - { - NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); - } + if (rc < 0) + { + NS_FATAL_ERROR ("Error at xmlTextWriterStartElement"); + } + std::string fullname = m_typeid + "::" + name; + rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "name", + BAD_CAST fullname.c_str ()); + if (rc < 0) + { + NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); + } + rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "value", + BAD_CAST defaultValue.c_str ()); + if (rc < 0) + { + NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); + } rc = xmlTextWriterEndElement(m_writer); if (rc < 0) - { - NS_FATAL_ERROR ("Error at xmlTextWriterEndElement"); - } + { + NS_FATAL_ERROR ("Error at xmlTextWriterEndElement"); + } } xmlTextWriterPtr m_writer; std::string m_typeid; @@ -128,36 +128,36 @@ XmlConfigSave::Attributes (void) { class XmlTextAttributeIterator : public AttributeIterator { - public: +public: XmlTextAttributeIterator (xmlTextWriterPtr writer) : m_writer (writer) {} - private: +private: virtual void DoVisitAttribute (Ptr object, std::string name) { StringValue str; object->GetAttribute (name, str); int rc; rc = xmlTextWriterStartElement(m_writer, BAD_CAST "value"); if (rc < 0) - { - NS_FATAL_ERROR ("Error at xmlTextWriterStartElement"); - } + { + NS_FATAL_ERROR ("Error at xmlTextWriterStartElement"); + } rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "path", - BAD_CAST GetCurrentPath ().c_str ()); + BAD_CAST GetCurrentPath ().c_str ()); if (rc < 0) - { - NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); - } + { + NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); + } rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "value", - BAD_CAST str.Get ().c_str ()); + BAD_CAST str.Get ().c_str ()); if (rc < 0) - { - NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); - } + { + NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); + } rc = xmlTextWriterEndElement(m_writer); if (rc < 0) - { - NS_FATAL_ERROR ("Error at xmlTextWriterEndElement"); - } + { + NS_FATAL_ERROR ("Error at xmlTextWriterEndElement"); + } } xmlTextWriterPtr m_writer; }; @@ -176,27 +176,27 @@ XmlConfigSave::Global (void) (*i)->GetValue (value); rc = xmlTextWriterStartElement(m_writer, BAD_CAST "global"); - if (rc < 0) - { - NS_FATAL_ERROR ("Error at xmlTextWriterStartElement"); - } - rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "name", - BAD_CAST (*i)->GetName ().c_str ()); - if (rc < 0) - { - NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); - } - rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "value", - BAD_CAST value.Get ().c_str ()); - if (rc < 0) - { - NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); - } + if (rc < 0) + { + NS_FATAL_ERROR ("Error at xmlTextWriterStartElement"); + } + rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "name", + BAD_CAST (*i)->GetName ().c_str ()); + if (rc < 0) + { + NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); + } + rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "value", + BAD_CAST value.Get ().c_str ()); + if (rc < 0) + { + NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); + } rc = xmlTextWriterEndElement(m_writer); - if (rc < 0) - { - NS_FATAL_ERROR ("Error at xmlTextWriterEndElement"); - } + if (rc < 0) + { + NS_FATAL_ERROR ("Error at xmlTextWriterEndElement"); + } } } @@ -229,26 +229,26 @@ XmlConfigLoad::Default (void) { const xmlChar *type = xmlTextReaderConstName(reader); if (type == 0) - { - NS_FATAL_ERROR ("Invalid value"); - } + { + NS_FATAL_ERROR ("Invalid value"); + } if (std::string ((char*)type) == "default") - { - xmlChar *name = xmlTextReaderGetAttribute (reader, BAD_CAST "name"); - if (name == 0) - { - NS_FATAL_ERROR ("Error getting attribute 'name'"); - } - xmlChar *value = xmlTextReaderGetAttribute (reader, BAD_CAST "value"); - if (value == 0) - { - NS_FATAL_ERROR ("Error getting attribute 'value'"); - } - NS_LOG_DEBUG ("default="<<(char*)name<<", value=" <