Tuesday 22 February 2011

CSRInstrument::SetModelName

When modifying instruments using the Sophis API, one would normally expect to call Clone_API() first and then modify the instrument accordingly. This is because the instruments are cached locally and to edit them directly is to change them in the cache in a non-thread safe (this is Sophis, remember) way. So, use Clone_API() first.

However, the documentation for SetModelName() says to call Clone afterwards!

Mysteriously, calling Clone after SetModelName resets the modified flag in the object to false. I suppose it's not that mysterious really. Anyway, the upshot of this is that it would appear to be necessary to manually set the modified flag using SetModified(true). Then Save() will actually persist the updated model name to titres!

Note, however, that it is still necessary to call Clone before SetModelName as well! Goodness gracious!

Failure to call Clone after SetModelName results in an exception being thrown from the depths of the Sophis toolkit bearing a message which politely informs one of the need to use Clone afterwards. Just so that you know.

No comments:

Post a Comment