ALMA Computing Group

ErrorComponent Class Reference
[ACS Components Examples]

This class shows how to deal with errors in components. More...

#include <acsexmplErrorComponentImpl.h>

List of all members.

Public Member Functions

 ErrorComponent (const ACE_CString &name, maci::ContainerServices *containerServices)
 Constructor.
virtual ~ErrorComponent ()
 Destructor.
virtual void displayMessage ()
 Displays "Hello World" to the console.
virtual void badMethod (CORBA::Short depth)
 Simple method raises a remote exception within the calling client.
virtual void exceptionFromCompletion (CORBA::Short depth)
 Simple method raises a remote exception within the calling client.
virtual void typeException (CORBA::Short depth)
 This method throws a REMOTE (CORBA) type exception if depth>0.
virtual void corbaSystemException ()
 Method that throws a CORBA::BAD_PARAM system exception to show how to handle CORBA System Exceptions.
virtual ACSErr::Completion * completionFromException (CORBA::Short depth)
 Simple method that returns an ACSErr::Completion, where an error trace is added from an exception.
virtual ACSErr::Completion * completionFromCompletion (CORBA::Short depth)
 Simple method that returns a REMOTE (CORBA) completion (ACSErr::Completion), where an error trace is added from a completion.
ACSErr::Completion * completionOnStack (CORBA::Short depth)
 This method is similar than completionFromCompletion, but it allocated C++ completion on the stack instead on the heap.
void outCompletion (ACSErr::Completion_out comp)
 Simple method that returns an ACSErr::Completion as an out parameter.

Private Member Functions

virtual ACSErr::CompletionImpl * createCompletion (unsigned short depth)
 This method return a LOCAL (C++) completion which contains an error trace if depth > 0, otherwise it returns non error completion (ACSErrOKCompletion), i.e.
virtual void buildErrorTrace (unsigned short depth)
 The aim of this method is to build an error trace.


Detailed Description

This class shows how to deal with errors in components.

All components should inherit from CharacteristicComponentImpl or it's superclass, ACSComponentImpl, to remain compatiable with ACS tools such as objexp (i.e., a GUI used to manipulate components). This class also derives from POA_acsexmplErrorComponent::ErrorComponent which is a class automatically generated by CORBA from ErrorComponent's IDL file.

Version:
"@(#) $Id: acsexmplErrorComponentImpl.h,v 1.10 2008/10/09 08:41:11 cparedes Exp $"

Definition at line 106 of file acsexmplErrorComponentImpl.h.


Constructor & Destructor Documentation

ErrorComponent::ErrorComponent const ACE_CString &  name,
maci::ContainerServices *  containerServices
 

Constructor.

Parameters:
poa Poa which will activate this and also all other components. Developers need not be concerned with what a PortableServer does...just pass it to the superclass's constructor.
name component's name. All components have a name associated with them so other components and clients can access them.
Definition at line 40 of file acsexmplErrorComponentImpl.cpp.

ErrorComponent::~ErrorComponent  )  [virtual]
 

Destructor.

Definition at line 49 of file acsexmplErrorComponentImpl.cpp.


Member Function Documentation

void ErrorComponent::badMethod CORBA::Short  depth  )  [virtual]
 

Simple method raises a remote exception within the calling client.

Implementation of IDL badMethod().

Parameters:
depth depth of the error trace
Exceptions:
ACSErrTypeCommon::GenericErrorEx 
ACSErrTypeCommon::UnexpectedExceptionEx 

Definition at line 64 of file acsexmplErrorComponentImpl.cpp.

References buildErrorTrace().

void ErrorComponent::buildErrorTrace unsigned short  depth  )  [private, virtual]
 

The aim of this method is to build an error trace.

It builds the error trace using exception, but the same could be done using Completion. It simply throw an exception containing an error trace with the requested depth, if > 0 Otherwise just returns.

Notice that this method throws a LOCAL exception xxxExImpl and not a remote exception xxx

Parameters:
depth depth of the error trace
Exceptions:
ACSErrTypeCommon::GenericErrorExImpl 
Definition at line 330 of file acsexmplErrorComponentImpl.cpp.

Referenced by badMethod(), createCompletion(), and typeException().

ACSErr::Completion * ErrorComponent::completionFromCompletion CORBA::Short  depth  )  [virtual]
 

Simple method that returns a REMOTE (CORBA) completion (ACSErr::Completion), where an error trace is added from a completion.

Parameters:
depth depth of the error trace, if <=0, returns OK completion
Returns:
ACSErr::Completion *

*
Definition at line 234 of file acsexmplErrorComponentImpl.cpp.

References createCompletion().

ACSErr::Completion * ErrorComponent::completionFromException CORBA::Short  depth  )  [virtual]
 

Simple method that returns an ACSErr::Completion, where an error trace is added from an exception.

Parameters:
depth depth of the error trace, if <=0, returns OK completion
Returns:
ACSErr::Completion *

*
Definition at line 142 of file acsexmplErrorComponentImpl.cpp.

References createCompletion().

ACSErr::Completion * ErrorComponent::completionOnStack CORBA::Short  depth  ) 
 

This method is similar than completionFromCompletion, but it allocated C++ completion on the stack instead on the heap.

Parameters:
depth depth of the error trace, if <=0, returns OK completion
Returns:
ACSErr::Completion *

*
Definition at line 156 of file acsexmplErrorComponentImpl.cpp.

References createCompletion().

void ErrorComponent::corbaSystemException  )  [virtual]
 

Method that throws a CORBA::BAD_PARAM system exception to show how to handle CORBA System Exceptions.

Definition at line 136 of file acsexmplErrorComponentImpl.cpp.

CompletionImpl * ErrorComponent::createCompletion unsigned short  depth  )  [private, virtual]
 

This method return a LOCAL (C++) completion which contains an error trace if depth > 0, otherwise it returns non error completion (ACSErrOKCompletion), i.e.

completion w/o ane error trace

Parameters:
depth depth of the error trace
Definition at line 278 of file acsexmplErrorComponentImpl.cpp.

References buildErrorTrace().

Referenced by completionFromCompletion(), completionFromException(), completionOnStack(), and exceptionFromCompletion().

void ErrorComponent::displayMessage  )  [virtual]
 

Displays "Hello World" to the console.

Implementation of IDL displayMessage().


Definition at line 57 of file acsexmplErrorComponentImpl.cpp.

void ErrorComponent::exceptionFromCompletion CORBA::Short  depth  )  [virtual]
 

Simple method raises a remote exception within the calling client.

The error trace in the exception is added from a completion. Implementation of IDL method.

Parameters:
depth depth of the error trace
Exceptions:
ACSErrTypeCommon::GenericErrorEx 

Definition at line 195 of file acsexmplErrorComponentImpl.cpp.

References createCompletion().

void ErrorComponent::outCompletion ACSErr::Completion_out  comp  ) 
 

Simple method that returns an ACSErr::Completion as an out parameter.

Parameters:
comp Completion as out parameter *

*
Definition at line 268 of file acsexmplErrorComponentImpl.cpp.

void ErrorComponent::typeException CORBA::Short  depth  )  [virtual]
 

This method throws a REMOTE (CORBA) type exception if depth>0.

If we want to throw a type exception we have to specfy this in the method signature. In this example the method can throw: ACSErrTypeCommon::GenericErrorEx or ACSErrTypeCommon::ACSErrTypeCommonEx exceptions. Although GenericErrorEx derives from ACSErrTypeCommonEx we have to specfy both in the method signature because IDL does not support hierarchy of exceptions.

Parameters:
depth depth of the error trace
Exceptions:
ACSErrTypeCommon::GenericErrorEx 
ACSErrTypeCommon::ACSErrTypeCommonEx 

Definition at line 100 of file acsexmplErrorComponentImpl.cpp.

References buildErrorTrace().


The documentation for this class was generated from the following files: