[mlpack-svn] r13798 - mlpack/trunk/src/mlpack/core/util

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Oct 31 14:12:28 EDT 2012


Author: rcurtin
Date: 2012-10-31 14:12:27 -0400 (Wed, 31 Oct 2012)
New Revision: 13798

Modified:
   mlpack/trunk/src/mlpack/core/util/cli.cpp
   mlpack/trunk/src/mlpack/core/util/cli.hpp
   mlpack/trunk/src/mlpack/core/util/cli_deleter.cpp
   mlpack/trunk/src/mlpack/core/util/cli_deleter.hpp
   mlpack/trunk/src/mlpack/core/util/cli_impl.hpp
   mlpack/trunk/src/mlpack/core/util/log.cpp
   mlpack/trunk/src/mlpack/core/util/log.hpp
   mlpack/trunk/src/mlpack/core/util/nulloutstream.hpp
   mlpack/trunk/src/mlpack/core/util/option.cpp
   mlpack/trunk/src/mlpack/core/util/option.hpp
   mlpack/trunk/src/mlpack/core/util/option_impl.hpp
   mlpack/trunk/src/mlpack/core/util/prefixedoutstream.cpp
   mlpack/trunk/src/mlpack/core/util/prefixedoutstream.hpp
   mlpack/trunk/src/mlpack/core/util/prefixedoutstream_impl.hpp
   mlpack/trunk/src/mlpack/core/util/save_restore_utility.cpp
   mlpack/trunk/src/mlpack/core/util/save_restore_utility.hpp
   mlpack/trunk/src/mlpack/core/util/save_restore_utility_impl.hpp
Log:
Move everything into the mlpack::util namespace from mlpack::io or
mlpack::utilities.


Modified: mlpack/trunk/src/mlpack/core/util/cli.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/cli.cpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/cli.cpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -31,7 +31,7 @@
 #include "option.hpp"
 
 using namespace mlpack;
-using namespace mlpack::io;
+using namespace mlpack::util;
 
 CLI* CLI::singleton = NULL;
 

Modified: mlpack/trunk/src/mlpack/core/util/cli.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/cli.hpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/cli.hpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -6,8 +6,8 @@
  * This can be used more or less regardless of context.  In the future,
  * it might be expanded to include file I/O.
  */
-#ifndef __MLPACK_CORE_IO_CLI_HPP
-#define __MLPACK_CORE_IO_CLI_HPP
+#ifndef __MLPACK_CORE_UTIL_CLI_HPP
+#define __MLPACK_CORE_UTIL_CLI_HPP
 
 #include <list>
 #include <iostream>
@@ -35,8 +35,8 @@
  *     care of by CLI (however, you can explicitly specify newlines to denote
  *     new paragraphs).
  */
-#define PROGRAM_INFO(NAME, DESC) static mlpack::io::ProgramDoc \
-    io_programdoc_dummy_object = mlpack::io::ProgramDoc(NAME, DESC);
+#define PROGRAM_INFO(NAME, DESC) static mlpack::util::ProgramDoc \
+    io_programdoc_dummy_object = mlpack::util::ProgramDoc(NAME, DESC);
 
 /**
  * Define a flag parameter.
@@ -323,13 +323,14 @@
  * @param REQ Whether or not parameter is required (boolean value).
  */
 #ifdef __COUNTER__
-  #define PARAM(T, ID, DESC, ALIAS, DEF, REQ) static mlpack::io::Option<T> \
+  #define PARAM(T, ID, DESC, ALIAS, DEF, REQ) static mlpack::util::Option<T> \
       JOIN(io_option_dummy_object_, __COUNTER__) \
       (false, DEF, ID, DESC, ALIAS, REQ);
 
   /** @cond Don't document internal macros. */
-  #define PARAM_FLAG_INTERNAL(ID, DESC, ALIAS) static mlpack::io::Option<bool>\
-  JOIN(__io_option_flag_object_, __COUNTER__) (ID, DESC, ALIAS);
+  #define PARAM_FLAG_INTERNAL(ID, DESC, ALIAS) static \
+      mlpack::util::Option<bool> JOIN(__io_option_flag_object_, __COUNTER__) \
+      (ID, DESC, ALIAS);
   /** @endcond */
 
 #else
@@ -337,13 +338,14 @@
   // don't think we can absolutely guarantee success, but it should be "good
   // enough".  We use the __LINE__ macro and the type of the parameter to try
   // and get a good guess at something unique.
-  #define PARAM(T, ID, DESC, ALIAS, DEF, REQ) static mlpack::io::Option<T> \
+  #define PARAM(T, ID, DESC, ALIAS, DEF, REQ) static mlpack::util::Option<T> \
       JOIN(JOIN(io_option_dummy_object_, __LINE__), opt) (false, DEF, ID, \
       DESC, ALIAS, REQ);
 
   /** @cond Don't document internal macros. */
-  #define PARAM_FLAG_INTERNAL(ID, DESC, ALIAS) static mlpack::io::Option<bool>\
-      JOIN(__io_option_flag_object_, __LINE__) (ID, DESC, ALIAS);
+  #define PARAM_FLAG_INTERNAL(ID, DESC, ALIAS) static \
+      mlpack::util::Option<bool> JOIN(__io_option_flag_object_, __LINE__) \
+      (ID, DESC, ALIAS);
   /** @endcond */
 
 #endif
@@ -357,13 +359,13 @@
 
 namespace mlpack {
 
-namespace io {
+namespace util {
 
 // Externally defined in option.hpp, this class holds information about the
 // program being run.
 class ProgramDoc;
 
-}; // namespace io
+}; // namespace util
 
 /**
  * Aids in the extensibility of CLI by focusing potential
@@ -556,7 +558,7 @@
   static void AddFlag(const std::string& identifier,
                       const std::string& description,
                       const std::string& alias = "");
-  
+
   /**
    * Parses the parameters for 'help' and 'info'.
    * If found, will print out the appropriate information and kill the program.
@@ -628,7 +630,7 @@
   /**
    * Removes duplicate flags.
    *
-   * @param bpo The basic_program_options to remove duplicate flags from. 
+   * @param bpo The basic_program_options to remove duplicate flags from.
    */
   static void RemoveDuplicateFlags(po::basic_parsed_options<char>& bpo);
 
@@ -656,7 +658,7 @@
    *
    * @param doc Pointer to the ProgramDoc object.
    */
-  static void RegisterProgramDoc(io::ProgramDoc* doc);
+  static void RegisterProgramDoc(util::ProgramDoc* doc);
 
   /**
    * Destructor.
@@ -695,7 +697,7 @@
 
  public:
   //! Pointer to the ProgramDoc object.
-  io::ProgramDoc *doc;
+  util::ProgramDoc *doc;
 
  private:
   /**
@@ -714,7 +716,7 @@
    * @return The alias associated with value.
    */
   static std::string AliasReverseLookup(const std::string& value);
- 
+
 #ifdef _WIN32
   /**
    * Converts a FILETIME structure to an equivalent timeval structure.

Modified: mlpack/trunk/src/mlpack/core/util/cli_deleter.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/cli_deleter.cpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/cli_deleter.cpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -1,5 +1,5 @@
 /**
- * @file io_deleter.cc
+ * @file cli_deleter.cpp
  * @author Ryan Curtin
  *
  * Extremely simple class whose only job is to delete the existing CLI object at
@@ -12,14 +12,14 @@
 #include "cli.hpp"
 
 using namespace mlpack;
-using namespace mlpack::io;
+using namespace mlpack::util;
 
 /***
  * Empty constructor that does nothing.
  */
 CLIDeleter::CLIDeleter()
 {
-  /* nothing to do */
+  /* Nothing to do. */
 }
 
 /***

Modified: mlpack/trunk/src/mlpack/core/util/cli_deleter.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/cli_deleter.hpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/cli_deleter.hpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -4,11 +4,11 @@
  *
  * Definition of the CLIDeleter() class.
  */
-#ifndef __MLPACK_CORE_IO_CLI_DELETER_HPP
-#define __MLPACK_CORE_IO_CLI_DELETER_HPP
+#ifndef __MLPACK_CORE_UTIL_CLI_DELETER_HPP
+#define __MLPACK_CORE_UTIL_CLI_DELETER_HPP
 
 namespace mlpack {
-namespace io {
+namespace util {
 
 /**
  * Extremely simple class whose only job is to delete the existing CLI object at

Modified: mlpack/trunk/src/mlpack/core/util/cli_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/cli_impl.hpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/cli_impl.hpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -4,8 +4,8 @@
  *
  * Implementation of templated functions of the CLI class.
  */
-#ifndef __MLPACK_CORE_IO_CLI_IMPL_HPP
-#define __MLPACK_CORE_IO_CLI_IMPL_HPP
+#ifndef __MLPACK_CORE_UTIL_CLI_IMPL_HPP
+#define __MLPACK_CORE_UTIL_CLI_IMPL_HPP
 
 // In case it has not already been included.
 #include "cli.hpp"
@@ -29,9 +29,9 @@
  */
 template<typename T>
 void CLI::Add(const std::string& path,
-             const std::string& description,
-             const std::string& alias,
-             bool required)
+              const std::string& description,
+              const std::string& alias,
+              bool required)
 {
 
   po::options_description& desc = CLI::GetSingleton().desc;

Modified: mlpack/trunk/src/mlpack/core/util/log.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/log.cpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/log.cpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -27,7 +27,7 @@
 #endif
 
 using namespace mlpack;
-using namespace mlpack::io;
+using namespace mlpack::util;
 
 // Only output debugging output if in debug mode.
 #ifdef DEBUG

Modified: mlpack/trunk/src/mlpack/core/util/log.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/log.hpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/log.hpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -55,28 +55,29 @@
    * If not, halts program execution and prints a custom error message.
    * Does nothing in non-debug mode.
    */
-  static void Assert(bool condition, const std::string& message = std::string("Assert Failed."));
+  static void Assert(bool condition,
+                     const std::string& message = "Assert Failed.");
 
 
   // We only use PrefixedOutStream if the program is compiled with debug
   // symbols.
 #ifdef DEBUG
   //! Prints debug output with the appropriate tag: [DEBUG].
-  static io::PrefixedOutStream Debug;
+  static util::PrefixedOutStream Debug;
 #else
   //! Dumps debug output into the bit nether regions.
-  static io::NullOutStream Debug;
+  static util::NullOutStream Debug;
 #endif
 
   //! Prints informational messages if --verbose is specified, prefixed with
   //! [INFO ].
-  static io::PrefixedOutStream Info;
+  static util::PrefixedOutStream Info;
 
   //! Prints warning messages prefixed with [WARN ].
-  static io::PrefixedOutStream Warn;
+  static util::PrefixedOutStream Warn;
 
   //! Prints fatal messages prefixed with [FATAL], then terminates the program.
-  static io::PrefixedOutStream Fatal;
+  static util::PrefixedOutStream Fatal;
 
   //! Reference to cout, if necessary.
   static std::ostream& cout;

Modified: mlpack/trunk/src/mlpack/core/util/nulloutstream.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/nulloutstream.hpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/nulloutstream.hpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -5,15 +5,15 @@
  *
  * Definition of the NullOutStream class.
  */
-#ifndef __MLPACK_CORE_IO_NULLOUTSTREAM_HPP
-#define __MLPACK_CORE_IO_NULLOUTSTREAM_HPP
+#ifndef __MLPACK_CORE_UTIL_NULLOUTSTREAM_HPP
+#define __MLPACK_CORE_UTIL_NULLOUTSTREAM_HPP
 
 #include <iostream>
 #include <streambuf>
 #include <string>
 
 namespace mlpack {
-namespace io {
+namespace util {
 
 /**
  * Used for Log::Debug when not compiled with debugging symbols.  This class
@@ -34,7 +34,7 @@
 
   /*
    We use (void) paramName in order to avoid the warning generated by
-   -Wextra. For some currently unknown reason, simply deleting the 
+   -Wextra. For some currently unknown reason, simply deleting the
    parameter name (aka, outperator<<(bool) {...}) causes a compilation
    error (with -Werror off) for only this class.
    */
@@ -82,7 +82,7 @@
   { (void) s; return *this; }
 };
 
-} // namespace io
+} // namespace util
 } // namespace mlpack
 
 #endif

Modified: mlpack/trunk/src/mlpack/core/util/option.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/option.cpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/option.cpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -11,7 +11,7 @@
 #include <string>
 
 using namespace mlpack;
-using namespace mlpack::io;
+using namespace mlpack::util;
 using namespace std;
 
 /**

Modified: mlpack/trunk/src/mlpack/core/util/option.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/option.hpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/option.hpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -13,7 +13,7 @@
 #include "cli.hpp"
 
 namespace mlpack {
-namespace io {
+namespace util {
 
 /**
  * A static object whose constructor registers a parameter with the CLI class.
@@ -93,7 +93,7 @@
   std::string documentation;
 };
 
-}; // namespace io
+}; // namespace util
 }; // namespace mlpack
 
 // For implementations of templated functions

Modified: mlpack/trunk/src/mlpack/core/util/option_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/option_impl.hpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/option_impl.hpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -11,18 +11,18 @@
 #include "option.hpp"
 
 namespace mlpack {
-namespace io {
+namespace util {
 
 /**
  * Registers a parameter with CLI.
  */
 template<typename N>
 Option<N>::Option(bool ignoreTemplate,
-                N defaultValue,
-                const std::string& identifier,
-         	const std::string& description,
-         	const std::string& alias,
-                bool required)
+                  N defaultValue,
+                  const std::string& identifier,
+                  const std::string& description,
+                  const std::string& alias,
+                  bool required)
 {
   if (ignoreTemplate)
   {
@@ -31,7 +31,6 @@
   else
   {
     CLI::Add<N>(identifier, description, alias, required);
-
     CLI::GetParam<N>(identifier) = defaultValue;
   }
 }
@@ -42,13 +41,13 @@
  */
 template<typename N>
 Option<N>::Option(const std::string& identifier,
-         	const std::string& description,
-         	const std::string& alias)
+                  const std::string& description,
+                  const std::string& alias)
 {
   CLI::AddFlag(identifier, description, alias);
 }
 
-}; // namespace io
+}; // namespace util
 }; // namespace mlpack
 
 #endif

Modified: mlpack/trunk/src/mlpack/core/util/prefixedoutstream.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/prefixedoutstream.cpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/prefixedoutstream.cpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -13,7 +13,7 @@
 
 #include "prefixedoutstream.hpp"
 
-using namespace mlpack::io;
+using namespace mlpack::util;
 
 /**
  * These are all necessary because gcc's template mechanism does not seem smart

Modified: mlpack/trunk/src/mlpack/core/util/prefixedoutstream.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/prefixedoutstream.hpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/prefixedoutstream.hpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -20,7 +20,7 @@
 #include <mlpack/core/util/sfinae_utility.hpp>
 
 namespace mlpack {
-namespace io {
+namespace util {
 
 /**
  * Allows us to output to an ostream with a prefix at the beginning of each
@@ -116,7 +116,7 @@
 
  private:
   HAS_MEM_FUNC(ToString, HasToString)
-  
+
   //! This handles forwarding all primitive types transparently
   template<typename T>
   void CallBaseLogic(T s,
@@ -124,7 +124,7 @@
           boost::is_class<T>
       >::type*);
 
-  //! Forward all objects that do not implement a ToString() method 
+  //! Forward all objects that do not implement a ToString() method
   template<typename T>
   void CallBaseLogic(T s,
       typename boost::enable_if<
@@ -133,7 +133,7 @@
       typename boost::disable_if<
           HasToString<T, std::string(T::*)() const>
       >::type*);
-  
+
   //! Call ToString() on all objects that implement ToString() before forwarding
   template<typename T>
   void CallBaseLogic(T s,
@@ -171,10 +171,10 @@
   bool fatal;
 };
 
-// Template definitions
+}; // namespace util
+}; // namespace mlpack
+
+// Template definitions.
 #include "prefixedoutstream_impl.hpp"
 
-} // namespace io
-} // namespace mlpack
-
 #endif

Modified: mlpack/trunk/src/mlpack/core/util/prefixedoutstream_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/prefixedoutstream_impl.hpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/prefixedoutstream_impl.hpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -12,6 +12,9 @@
 #include "prefixedoutstream.hpp"
 #include <iostream>
 
+namespace mlpack {
+namespace util {
+
 template<typename T>
 PrefixedOutStream& PrefixedOutStream::operator<<(T s)
 {
@@ -20,17 +23,17 @@
 }
 
 //! This handles forwarding all primitive types transparently
-template<typename T> 
+template<typename T>
 void PrefixedOutStream::CallBaseLogic(T s,
     typename boost::disable_if<
         boost::is_class<T>
     >::type* = 0)
-{ 
+{
   BaseLogic<T>(s);
 }
 
 // Forward all objects that do not implement a ToString() method transparently
-template<typename T> 
+template<typename T>
 void PrefixedOutStream::CallBaseLogic(T s,
     typename boost::enable_if<
         boost::is_class<T>
@@ -38,12 +41,12 @@
     typename boost::disable_if<
         HasToString<T, std::string(T::*)() const>
     >::type* = 0)
-{ 
+{
   BaseLogic<T>(s);
 }
 
 // Call ToString() on all objects that implement ToString() before forwarding
-template<typename T> 
+template<typename T>
 void PrefixedOutStream::CallBaseLogic(T s,
     typename boost::enable_if<
         boost::is_class<T>
@@ -51,7 +54,7 @@
     typename boost::enable_if<
         HasToString<T, std::string(T::*)() const>
     >::type* = 0)
-{ 
+{
   std::string result = s.ToString();
   BaseLogic<std::string&>(result);
 }
@@ -68,7 +71,7 @@
   PrefixIfNeeded();
 
   std::ostringstream convert;
-  convert << val;  
+  convert << val;
 
   if(convert.fail())
   {
@@ -143,4 +146,7 @@
   }
 }
 
+}; // namespace util
+}; // namespace mlpack
+
 #endif // MLPACK_CLI_PREFIXEDOUTSTREAM_IMPL_H

Modified: mlpack/trunk/src/mlpack/core/util/save_restore_utility.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/save_restore_utility.cpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/save_restore_utility.cpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -8,7 +8,7 @@
 #include "save_restore_utility.hpp"
 
 using namespace mlpack;
-using namespace utilities;
+using namespace mlpack::util;
 
 bool SaveRestoreUtility::ReadFile(const std::string& filename)
 {

Modified: mlpack/trunk/src/mlpack/core/util/save_restore_utility.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/save_restore_utility.hpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/save_restore_utility.hpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -22,7 +22,7 @@
 #include <mlpack/core.hpp>
 
 namespace mlpack {
-namespace utilities {
+namespace util {
 
 class SaveRestoreUtility
 {
@@ -113,11 +113,10 @@
 void SaveRestoreUtility::SaveParameter(const arma::vec& t,
                                        const std::string& name);
 
-} /* namespace utilities */
-} /* namespace mlpack */
+}; /* namespace util */
+}; /* namespace mlpack */
 
+// Include implementation.
 #include "save_restore_utility_impl.hpp"
 
-
-
 #endif

Modified: mlpack/trunk/src/mlpack/core/util/save_restore_utility_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/save_restore_utility_impl.hpp	2012-10-31 16:08:03 UTC (rev 13797)
+++ mlpack/trunk/src/mlpack/core/util/save_restore_utility_impl.hpp	2012-10-31 18:12:27 UTC (rev 13798)
@@ -12,7 +12,7 @@
 #include "save_restore_utility.hpp"
 
 namespace mlpack {
-namespace utilities {
+namespace util {
 
 template<typename T>
 T& SaveRestoreUtility::LoadParameter(T& t, const std::string& name)
@@ -84,7 +84,7 @@
   parameters[name] = vectorAsStr;
 }
 
-}; // namespace utilities
+}; // namespace util
 }; // namespace mlpack
 
 #endif




More information about the mlpack-svn mailing list