Browse Source

[1975] Create constructor for DataSourceInfo

Michal 'vorner' Vaner 13 years ago
parent
commit
c4c3340828

+ 1 - 4
src/lib/datasrc/container.cc

@@ -49,10 +49,7 @@ ConfigurableContainer::configure(const Element& config, bool) {
             // Ask the factory to create the data source for us
             const DataSourcePair ds(this->getDataSource(type, paramConf));
             // And put it into the vector
-            DataSourceInfo info;
-            info.data_src_ = ds.first;
-            info.container_ = ds.second;
-            new_data_sources.push_back(info);
+            new_data_sources.push_back(DataSourceInfo(ds.first, ds.second));
         }
         // If everything is OK up until now, we have the new configuration
         // ready. So just put it there and let the old one die when we exit

+ 12 - 0
src/lib/datasrc/container.h

@@ -228,6 +228,18 @@ public:
     ///
     /// \todo The content yet to be defined.
     struct DataSourceInfo {
+        /// \brief Default constructor.
+        ///
+        /// Don't use directly. It is here so the structure can live in
+        /// a vector.
+        DataSourceInfo() :
+            data_src_(NULL)
+        {}
+        DataSourceInfo(DataSourceClient* data_src,
+                       const DataSourceClientContainerPtr& container) :
+            data_src_(data_src),
+            container_(container)
+        { }
         DataSourceClient* data_src_;
         DataSourceClientContainerPtr container_;
     };

+ 2 - 3
src/lib/datasrc/tests/container_unittest.cc

@@ -168,10 +168,9 @@ public:
     {
         for (size_t i(0); i < ds_count; ++ i) {
             shared_ptr<TestDS> ds(new TestDS(ds_zones[i]));
-            ConfigurableContainer::DataSourceInfo info;
-            info.data_src_ = ds.get();
             ds_.push_back(ds);
-            ds_info_.push_back(info);
+            ds_info_.push_back(ConfigurableContainer::DataSourceInfo(ds.get(),
+                DataSourceClientContainerPtr()));
         }
     }
     // Check the positive result is as we expect it.