[gme-users] probklems with findByID (BON2)

Berthing Jesper f35594 at Danfoss.com
Thu Nov 9 09:40:29 CST 2006


Hi Zoli,
 
Thanks for your reply.
 
The workaround works when I do not save or closes/reopens my model after
the objects where deleted. (An exception is thrown from BONimpl.cpp line
50) :
 
inline MON::ObjectPtr _getMetaBase( IMgaObject* spObject )

{

MON::ObjectPtr spMeta;

COMTHROW( spObject->get_MetaBase( spMeta.Addr() ) ); //<-- exception
thrown here

return spMeta;

}

But I am not able to figure out how this is related to the FindById
function?

 

To "solve" my problem I have removed the following line from the
FindByIDI: COMTHROW( m_spProject->GetObjectByID( Util::Copy( strID ),
spObject.Addr() ) );

and then it does not throw the exception but return NULL, if the model
where saved or closed/reopened after the objects where deleted.

ObjectImpl* ProjectImpl::findByIDI( const std::string& strID )

{

// Look for in Objects' cache

ObjectMapByID::iterator it = m_mapObjectsByID.find( strID );

if ( it != m_mapObjectsByID.end() )

return it->second;

// Retrieve and Attach

ObjectPtr spObject;

//COMTHROW( m_spProject->GetObjectByID( Util::Copy( strID ),
spObject.Addr() ) );

if ( ! spObject )

return NULL;

return ObjectImpl::attachI( spObject, this );

}

Best regards,
Jesper

________________________________

From: gme-users-bounces at list.isis.vanderbilt.edu
[mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf Of Zoltan
Molnar
Sent: 8. november 2006 20:17
To: gme-users
Subject: RE: [gme-users] probklems with findByID (BON2)


It seems that the current implementation of findById disregards object
status, which may be checked with ObjectImpl::getStatus() implemented as
follows:

ObjectStatus ObjectImpl::getStatus() const
{
long lStatus;
COMTHROW( m_spObject->get_Status( &lStatus ) );
switch ( lStatus ) {
case OBJECT_EXISTS :return OST_Exists;
case OBJECT_ZOMBIE :return OST_Zombie;
case OBJECT_DELETED :return OST_Deleted;
default :ASSERTTHROW( Util::Exception( "Unprocessed Object Status!" ) );
}
}
 
So until i implement a fix, please check the status of objects returned
by findById, like this:
Object obj = project->findByID("id-0065-00000008", false);
if(obj)
{
    project->consoleMsg( "Found", MSG_NORMAL);
    if( obj->getStatus() != OST_Exists)
        project->consoleMsg( "but it's a zombie", MSG_ERROR);
}

 

br, Zoli

 

	-----Original Message-----
	From: gme-users-bounces at list.isis.vanderbilt.edu
[mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf Of
Berthing Jesper
	Sent: Saturday, October 28, 2006 8:25 AM
	To: gme-users
	Subject: RE: [gme-users] probklems with findByID (BON2)
	
	
	Hi All,
	 
	I have some extra information to the problem I posted some days
ago.
	 
	1) When I delete some objects (Atoms) from my model and then
execute the interpreter, the function findByID returns that the delete
object still exists? (How can that be true if I deleted the objects
before executing the interpreter)
	 
	2) If I delete some objects from the model, save and close the
project and reopens it again, executes the interpreter. What tries to
execute the function findByID with the ID on the delete objects, an
exception is thown each time. Whereas the documentation says that a NULL
object should be returned.
	 
	I have tried to call the function with either true or false as
the secons parameter with no difference.
	 
	Has anybody any experience with this function? and its behaviour
or any clue what I could be doing wrong, please help me? ;-)
	 
	I am using GME version 6.5.8
	 
	Thanks.
	 
	Best regards,
	Jesper
	 
________________________________

	From: gme-users-bounces at list.isis.vanderbilt.edu
[mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf Of
Berthing Jesper
	Sent: 23. oktober 2006 20:08
	To: gme-users at list.isis.vanderbilt.edu
	Subject: [gme-users] probklems with findByID (BON2)
	
	
	
	

	Hi,
	
	I have a problem with the function findByID that throws an
exception on line 50 in bonimpl.cpp.
	
	Currently I am using the function in order to check the current
model against a backup model (XML) where I have the ID's stored of each
object. If the object is present in the current model it functions
correctly, but if it is not present the exception is thrown.
	
	Therefore, how should I use the function?
	
	Example:
	try
	{
	  if(0 == project->findByID("Id not present in the model",
true))
	  {
	        // Object with id not present
	  }
	  else
	  {
	        // Object with id present.
	  }
	}
	catch(BON::Exception& e)
	{
	        //print error
	}
	
	Best regards,
	Jesper
	

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.isis.vanderbilt.edu/pipermail/gme-users/attachments/20061109/0af73067/attachment.htm


More information about the gme-users mailing list