Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <typeinfo>
00032
00033 template<class T>
00034 mxml_node_t*
00035 cmtk::CommandLine::Item::Helper<T>
00036 ::MakeXML( const Item* item, mxml_node_t *const parent )
00037 {
00038 if ( ! (item->m_Properties & PROPS_NOXML) )
00039 {
00040 const char* typeName = CommandLineTypeTraits<T>::GetName();
00041
00042 mxml_node_t *node = NULL;
00043 if ( std::string( typeName ) == "string" )
00044 {
00045 if ( item->m_Properties & PROPS_IMAGE )
00046 {
00047 node = mxmlNewElement( parent, "image" );
00048
00049 if ( item->m_Properties & PROPS_LABELS )
00050 mxmlElementSetAttr( node, "type", "label" );
00051 else
00052 mxmlElementSetAttr( node, "type", "scalar" );
00053 }
00054 else if ( item->m_Properties & PROPS_XFORM )
00055 {
00056 node = mxmlNewElement( parent, "transform" );
00057 mxmlElementSetAttr( node, "fileExtensions", ".txt" );
00058 }
00059 else if ( item->m_Properties & PROPS_FILENAME )
00060 node = mxmlNewElement( parent, "file" );
00061 else if ( item->m_Properties & PROPS_DIRNAME )
00062 node = mxmlNewElement( parent, "directory" );
00063 else
00064 node = mxmlNewElement( parent, "string" );
00065
00066 if ( item->m_Properties & PROPS_OUTPUT )
00067 mxmlNewText( mxmlNewElement( node, "channel" ), 0, "output" );
00068 else
00069 mxmlNewText( mxmlNewElement( node, "channel" ), 0, "input" );
00070 }
00071 else
00072 node = mxmlNewElement( parent, typeName );
00073
00074
00075 for ( std::map<std::string,std::string>::const_iterator attrIt = item->m_Attributes.begin(); attrIt != item->m_Attributes.end(); ++attrIt )
00076 {
00077 mxmlElementSetAttr( node, attrIt->first.c_str(), attrIt->second.c_str() );
00078 }
00079
00080 return node;
00081 }
00082 return NULL;
00083 }
00084
00085 template<class T>
00086 std::string
00087 cmtk::CommandLine::Item::Helper<T>
00088 ::GetParamTypeString( const Item* item )
00089 {
00090 const std::string& typeName = CommandLineTypeTraits<T>::GetName();
00091
00092 if ( typeName == "string" )
00093 {
00094 if ( item->m_Properties & PROPS_IMAGE )
00095 {
00096 if ( item->m_Properties & PROPS_LABELS )
00097 return "<labelmap-path>";
00098 else
00099 return "<image-path>";
00100 }
00101 else if ( item->m_Properties & PROPS_XFORM )
00102 {
00103 return "<transformation-path>";
00104 }
00105 else if ( item->m_Properties & PROPS_FILENAME )
00106 return "<path>";
00107 else if ( item->m_Properties & PROPS_DIRNAME )
00108 return "<directory>";
00109 else
00110 return "<string>";
00111 }
00112
00113 return std::string("<")+typeName+std::string(">");
00114 }