//==== Add User Defined Parm ====// string UserParmContainer::AddParm(int type, const string & name, const string & group ) { Parm* p = ParmMgr.CreateParm( type ); if ( p ) { p->Init( name, group, this, 0.0, -1.0e6, 1.0e6, true ); p->SetDescript( "User Parm Descript" ); m_UserParmVec.push_back( p ); return p->GetID(); } return string(); }
//==== Decode Data From XML Data Struct ====// xmlNodePtr UserParmContainer::DecodeXml( xmlNodePtr & node ) { int num_curr_custom = m_UserParmVec.size() - m_NumPredefined; xmlNodePtr child_node = XmlUtil::GetNode( node, "UserParmContainer", 0 ); if ( child_node ) { int num_user = XmlUtil::FindInt( child_node, "NumUserParms", 0 ); //==== Decode All User Parms ====// if ( num_curr_custom == 0 ) { Renew( num_user ); for ( int i = 0; i < static_cast<int>( m_UserParmVec.size() ); i++ ) { xmlNodePtr pnode = XmlUtil::GetNode( child_node, "UserParm", i ); if ( pnode && m_UserParmVec[i] ) { m_UserParmVec[i]->DecodeXml( pnode, true ); } } } else { //==== Decode Predefined ====// for ( int i = 0; i < m_NumPredefined ; i++ ) { xmlNodePtr pnode = XmlUtil::GetNode( child_node, "UserParm", i ); if ( pnode && m_UserParmVec[i] ) { m_UserParmVec[i]->DecodeXml( pnode, true ); } } //==== Append New Custom ====// int num_new_custom = num_user - m_NumPredefined; for ( int i = 0 ; i < num_new_custom ; i++ ) { xmlNodePtr pnode = XmlUtil::GetNode( child_node, "UserParm", i + m_NumPredefined ); Parm* p = new Parm(); p->Init( "Temp", "User_Group", this, 0.0, -1.0e12, 1.0e12 ); p->DecodeXml( pnode, true ); m_UserParmVec.push_back( p ); } } } return child_node; }