Skip to content

Commit

Permalink
Add debug statements to try & figure out the mac issue. Refs #4399
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Apr 17, 2012
1 parent 56d855f commit 26a1ca0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions Code/Mantid/Framework/Kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set ( SRC_FILES
src/ISaveable.cpp
src/InstrumentInfo.cpp
src/Interpolation.cpp
src/IValidator.cpp
src/LibraryManager.cpp
src/LibraryWrapper.cpp
src/ListValidator.cpp
Expand Down
6 changes: 6 additions & 0 deletions Code/Mantid/Framework/Kernel/inc/MantidKernel/IValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class DLLExport IValidator
template <typename TYPE>
std::string isValid(const TYPE &value) const
{
g_log.debug() << "IValidator::isValid - Running check for value with typeid " << typeid(value).name() << "\n";
return runCheck(value, IsPtrType<TYPE>());
}

Expand Down Expand Up @@ -123,6 +124,7 @@ class DLLExport IValidator
template<typename T>
std::string runCheck(const T & value, const boost::false_type &) const
{
g_log.debug() << "IValidator::runCheck - Type is not a pointer type.\n";
const T *valuePtr = &value; // Avoid a copy by storing the pointer in the any holder
return check(boost::any(valuePtr));
}
Expand All @@ -133,6 +135,7 @@ class DLLExport IValidator
template<typename T>
std::string runCheck(const T & value, const boost::true_type &) const
{
g_log.debug() << "IValidator::runCheck - Type is a pointer type\n";
return runCheckWithDataItemPtr(value, boost::is_convertible<T, DataItem_sptr>());
}
/** Calls the validator for a pointer type that is NOT convertible to DataItem_sptr
Expand All @@ -142,6 +145,7 @@ class DLLExport IValidator
template<typename T>
std::string runCheckWithDataItemPtr(const T & value, const boost::false_type &) const
{
g_log.debug() << "IValidator::runCheck - Type is not a DataItem_sptr\n";
return check(boost::any(value));
}
/** Calls the validator for a pointer type that IS convertible to DataItem_sptr
Expand All @@ -151,9 +155,11 @@ class DLLExport IValidator
template<typename T>
std::string runCheckWithDataItemPtr(const T & value, const boost::true_type &) const
{
g_log.debug() << "IValidator::runCheck - Type is a DataItem_sptr\n";
return check(boost::any(boost::static_pointer_cast<DataItem>(value)));
}

static Logger & g_log;
};

} // namespace Kernel
Expand Down
11 changes: 11 additions & 0 deletions Code/Mantid/Framework/Kernel/inc/MantidKernel/TypedValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Includes
//----------------------------------------------------------------------
#include "MantidKernel/IValidator.h"
#include "MantidKernel/Logger.h"

namespace Mantid
{
Expand Down Expand Up @@ -111,12 +112,15 @@ namespace Mantid
*/
ElementType_sptr extractValue(const boost::any & value) const
{
g_log.debug() << "TypedValidator<boost::shared_ptr<T>>::extractValue. Value typeid " << value.type().name() << "\n";
if( value.type() == typeid(DataItem_sptr) )
{
g_log.debug() << "TypedValidator<boost::shared_ptr<T>>::extractValue. Typeid is DataItem_sptr\n";
return extractFromDataItem(value);
}
else
{
g_log.debug() << "TypedValidator<boost::shared_ptr<T>>::extractValue. Typeid is not a DataItem_sptr\n";
return extractFromSharedPtr(value);
}
}
Expand Down Expand Up @@ -152,7 +156,14 @@ namespace Mantid
throw std::invalid_argument("Value was not a shared_ptr type");
}
}

/// Logger
static Logger & g_log;
};

/// Initialize logger
template<typename T>
Logger & TypedValidator<boost::shared_ptr<T> >::g_log = Logger::get("TypedValidator");
}
}

Expand Down
10 changes: 10 additions & 0 deletions Code/Mantid/Framework/Kernel/src/IValidator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "MantidKernel/IValidator.h"

namespace Mantid
{
namespace Kernel
{
/// initialize static logger
Logger & IValidator::g_log = Logger::get("IValidator");
}
}

0 comments on commit 26a1ca0

Please sign in to comment.