![]() |
Telelogic Rhapsody (steve huntington) | ![]() |
Topic Title: Initializing static element Topic Summary: Created On: 9-Jan-2006 14:50 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
I have a static attibute in a class. The data type of this attribute is also a class (VxSemaphore). The constructor of this class needs 2 function parameters.
The generated code looks like this: // Static class member attribute VxSemaphore CQuadratureDecoder::mSemaphore = SEM_Q_FIFO, 0; Which Rhaposody property needs to be changed to generate the correct code like this: // Static class member attribute VxSemaphore CQuadratureDecoder::mSemaphore(SEM_Q_FIFO, 0); Regards |
|
![]() |
|
![]() |
|
Hi!
If the attribute was non-static, you could control the initialisation using the property CPP_CG::Attribute::InitializationStyle. This doesn't have any effect on static attribute initialisation, which appears rather like a defect to me! Would anyone from I-Logix care to comment on this? In the meantime, you could consider accessing your static semaphore using a static accessor function as follows: [CODE]VxSemaphore* CQuadratureDecoder::getItsVxSemaphore(void) { //#[ operation getItsVxSemaphore() static VxSemaphore itsVxSemaphore(SEM_Q_FIFO, 0); return &itsVxSemaphore; //#] }[/CODE] Better, in my view, would be to keep your model OS-independent by accessing your semaphore via an OMOSSemaphore base class pointer: [CODE]OMOSSemaphore* CQuadratureDecoder::getItsSemaphore(void) { //#[ operation getItsSemaphore() static OMOSSemaphore *itsSemaphore=NULL; if (itsSemaphore == NULL) { itsSemaphore = OMOSFactory::instance()->createOMOSSemaphore(SEM_Q_FIFO, 0); } return itsSemaphore; //#] }[/CODE] This function will return an Win32 semaphore object if you're running on the host, or a VxWorks semaphore object if you're running on a VxWorks target. The only proviso is that you need to take care over the meaning and availability of SEM_Q_FIFO on different operating systems. Even if this leads to custom initialisation code for your semaphore, at least the use of it will be OS-independent. best regards, Simon ------------------------- Simon Morrish simon.morrish@eu.panasonic.com http://panasonic.co.uk Panasonic ideas for life |
|
![]() |
|
![]() |
|
Hello Simon
Many thanks for your great help. It works. Best regards, Andreas Anderegg Hamilton Medical, Switzerland |
|
![]() |
Telelogic Rhapsody
» Rhapsody Category » Rhapsody
»
Initializing static element
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.