** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phantom.cpp,v 1.4 2000/06/22 10:17:28 kevin Exp $
+** $Id: phantom.cpp,v 1.5 2000/06/25 17:32:24 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
Phantom::PhantomID
Phantom::convertNameToPhantomID (const char* const phmName)
{
- PhantomID id;
+ PhantomID id = PHM_INVALID;
if (strcasecmp (phmName, PHM_HERMAN_STR) == 0)
id = PHM_HERMAN;
id = PHM_BROWLAND;
else if (strcasecmp (phmName, PHM_UNITPULSE_STR) == 0)
id = PHM_UNITPULSE;
- else
- id = PHM_INVALID;
return (id);
}
Phantom::createFromPhantom (const char* const phmName)
{
PhantomID phmid = convertNameToPhantomID (phmName);
- m_name = phmName;
+ if (phmid == PHM_INVALID) {
+ m_fail = true;
+ m_failMessage = "Invalid phantom name ";
+ m_failMessage += phmName;
+ return false;
+ }
+ m_name = phmName;
createFromPhantom (phmid);
}
addPElem ("ellipse", 0., 0., 1., 1., 0., 1.); // pulse
break;
default:
- sys_error (ERR_WARNING, "Illegal phantom id %d\n", phmid);
- m_name += " -- INVALID";
m_fail = true;
+ m_failMessage = "Illegal phantom id ";
+ m_failMessage += phmid;
return false;
- break;
}
m_id = phmid;