00001 00015 #pragma once 00016 00017 #include "CompositeLoggable.h" 00018 #include "LogContentsPrinter.h" 00019 #include "StreamOperators.h" 00020 00021 #include "TStd.h" 00022 #include <vector> 00023 00024 #include <boost/lexical_cast.hpp> 00025 #include <boost/foreach.hpp> 00026 00027 namespace Nvidia { 00028 namespace Logging { 00029 00035 template <typename T> 00036 class VectorLoggable : public CompositeLoggable 00037 { 00038 protected: 00040 const std::vector<T>& m_vector; 00041 00042 public: 00044 VectorLoggable(const std::vector<T>& vector) : m_vector(vector) {} 00045 00050 virtual void LogContentsOn(LogContentsPrinter& logContentsPrinter) const 00051 { 00052 BOOST_FOREACH(T item, m_vector) 00053 { 00054 logContentsPrinter.LogContent(_T(""), item); 00055 } 00056 } 00057 00059 virtual std::tstring GetTypeName() const 00060 { 00061 return boost::lexical_cast<std::tstring>(typeid(m_vector).name()); 00062 } 00063 00064 virtual std::tstring GetHumanReadableTypeName() const 00065 { 00066 return _T("vector"); 00067 } 00068 00070 virtual std::tstring GetStringValue() const 00071 { 00072 return boost::lexical_cast<std::tstring>(m_vector); 00073 } 00074 }; 00075 00076 } 00077 }