...
Python
Code Block |
---|
language | py |
---|
linenumbers | true |
---|
collapse | true |
---|
|
class <name>(...):
...
def initialize():
#Assign variable values
#Initialize data
...
def execute():
#Retrieve components
#Consider ready to receive calls (Change states if appropriate)
...
def cleanUp():
#Release components
#Release resources
...
def aboutToAbort():
#Do any critical clean up
#Continue with less critical stuff such as releasing components and other activities similar to cleanUp
...
... |
Java
Code Block |
---|
language | java |
---|
linenumbers | true |
---|
collapse | true |
---|
|
public class <name> ... {
...
public void initialize() {
//Assign variable values
//Initialize data
...
}
public void execute() {
//Retrieve components
//Consider ready to receive calls (Change states if appropriate)
...
}
public void cleanUp() {
//Release components
//Release resources
...
}
public void aboutToAbort() {
//Do any critical clean up
//Continue with less critical stuff such as releasing components and other activities similar to cleanUp
...
}
...
} |
C++
Code Block |
---|
language | cpp |
---|
linenumbers | true |
---|
collapse | true |
---|
|
class <name> : ... {
...
void initialize();
void execute();
void cleanUp();
void aboutToAbort();
...
}; |
Code Block |
---|
language | cpp |
---|
linenumbers | true |
---|
collapse | true |
---|
|
void <name>::initialize() {
//Assign variable values
//Initialize data
...
}
void <name>::execute() {
//Retrieve components
//Consider ready to receive calls (Change states if appropriate)
...
}
void <name>::cleanUp() {
//Release components
//Release resources
...
}
void <name>::aboutToAbort() {
//Do any critical clean up
//Continue with less critical stuff such as releasing components and other activities similar to cleanUp
...
} |
Retrieving and Releasing Components
During component interaction it will be needed to request and release components. When interacting with components from other components, you need to obtain the container services references to make the request to the Manager. Here we will show how to retrieve two types of components:
- Component By Name
- Default Component (By IDL)
Example Request and Release
Python
Code Block |
---|
language | py |
---|
linenumbers | true |
---|
collapse | true |
---|
|
#By Name
comp = self.getComponent("<Name>")
#By Interface. Must be at least one component configured as default!
comp = self.getDefaultComponent("IDL:<prefix>/<Module>/<Interface>:1.0")
#Release Components
self.releaseComponent(comp.name()) |
Java
Code Block |
---|
language | java |
---|
linenumbers | true |
---|
collapse | true |
---|
|
//Shared
import alma.<Module>.<Interface>;
import alma.<Module>.<Interface>Helper;
//By Name
<Interface> comp = <Interface>Helper.narrow(this.m_containerServices.getComponent("<Name>"));
//By Interface. Must be at least one component configured as default!
<Interface> comp = <Interface>Helper.narrow(this.m_containerServices.getDefaultComponent("IDL:<prefix>/<Module>/<Interface>:1.0"));
//Release Components
m_containerServies.releaseComponent(comp.name()); |
C++
Code Block |
---|
language | cpp |
---|
linenumbers | true |
---|
collapse | true |
---|
|
//By Name
<Module>::<Interface>_var comp = this->getContainerServices()->getComponent<<Module>::<Interface>>("<Name>");
//By Interface. Must be at least one component configured as default!
<Module>::<Interface>_var comp = this->getContainerServices()->getDefaultComponent<<Module>::<Interface>>("IDL:<prefix>/<Module>/<Interface>:1.0");
//Release Components
this->getContainerServices()->releaseComponent(comp->name()); |