/*========================================================================= Program: bbtk Module: $RCSfile: bbtkData.h,v $ Language: C++ Date: $Date: 2008/04/18 12:59:15 $ Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See doc/license.txt or http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ /** *\file *\brief Defines Data and DataInfo * * Data is bbtk general type exchanged between black boxes (adapted from boost::any). * DataInfo is the bbtk type of object storing informations on a data type : includes C++ type info (std::type_info) and a string describing the "nature" of the data (what is the content of the structure). */ #ifndef __bbtkData_h__ #define __bbtkData_h__ #include "bbtkAny.h" #include "bbtkRTTI.h" namespace bbtk { /// The generic type of "data" exchanged between black boxes typedef any Data; /// Object storing informations on a data type : includes C++ type info (std::type_info) and a string describing the "nature" of the data (what is the content of the structure) class DataInfo { public: DataInfo( TypeInfo type, const std::string& nature="") : mType(type), mNature(nature) {} ~DataInfo() {} TypeInfo GetType() const { return mType; } const std::string& GetNature() const { return mNature; } /// Equality bool operator== ( const DataInfo& k ) const { return ( (mType == k.mType) && (mNature == k.mNature) ); } /// Comparison bool operator< ( const DataInfo& k ) const { return ( ( mType.before(k.mType) ) || ( ( mType == k.mType ) && ( mNature.compare(k.mNature) < 0 ) ) ); } private: DataInfo() : mType(typeid(void)), mNature("") {} TypeInfo mType; std::string mNature; }; /// dump in a stream inline std::ostream& operator<<(std::ostream& s, const DataInfo& d) { s << "<" << TypeName(d.GetType()) << "("<< d.GetNature()<<")>"; return s; } }// namespace bbtk #endif