ACF $AcfVersion:0$
Public Types | Protected Member Functions | List of all members
ilog::CStandardStreamBridgeComp Class Reference

Component wrapper for standard stream bridging. More...

#include <CStandardStreamBridgeComp.h>

Inheritance diagram for ilog::CStandardStreamBridgeComp:
icomp::CComponentBase icomp::IComponent istd::IPolymorphic

Public Types

typedef icomp::CComponentBase BaseClass
 Base class typedef.
 

Protected Member Functions

virtual void OnComponentCreated () override
 
virtual void OnComponentDestroyed () override
 
- Protected Member Functions inherited from icomp::CComponentBase
bool IsComponentActive () const
 Check if component is active.
 
virtual const icomp::IRealComponentStaticInfoGetComponentStaticInfo () const =0
 Get access to static info of this component.
 

Additional Inherited Members

- Public Member Functions inherited from icomp::CComponentBase
 CComponentBase ()
 Create component and assign it to specific context.
 
virtual const icomp::IComponentGetParentComponent (bool ownerOnly=false) const override
 Get parent of this component.
 
virtual void * GetInterface (const istd::CClassInfo &interfaceType, const QByteArray &subId="") override
 Get access to specified component interface.
 
virtual IComponentContextSharedPtr GetComponentContext () const override
 Get access to component context describing all application-specified component information loaded from components registry.
 
virtual void SetComponentContext (const IComponentContextSharedPtr &contextPtr, const icomp::IComponent *parentPtr, bool isParentOwner) override
 Set component context of this component.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 
- Static Protected Member Functions inherited from icomp::CComponentBase
static const icomp::IRealComponentStaticInfoInitStaticInfo (IComponent *componentPtr)
 
static QByteArray GetComponentId (const icomp::IComponentContext *componentContextPtr, const QByteArray &contextId=QByteArray())
 

Detailed Description

Component wrapper for standard stream bridging.

CStandardStreamBridgeComp provides a component-based interface for redirecting std::cout and std::cerr to the logging system. It creates and manages CStandardStreamBridge instances for both streams, automatically handling their lifecycle.

This is the recommended way to use stream bridging in ACF applications, as it integrates with the component system and handles initialization/cleanup properly.

Features
  • Automatically bridges both std::cout (as INFO) and std::cerr (as ERROR)
  • Component-based configuration and lifecycle management
  • Automatic cleanup when component is destroyed
  • Thread-safe stream redirection
Configuration
Component references:
  • SlaveMessageConsumer: Consumer to receive messages from streams (IMessageConsumer)
Usage Example
// Create log consumer
// Create bridge component
// Configure via .acc or programmatically:
// SlaveMessageConsumer -> logger
// Now all std::cout and std::cerr output goes to logger
std::cout << "This is logged as INFO" << std::endl;
std::cerr << "This is logged as ERROR" << std::endl;
// printf/fprintf also work (they use the same streams)
printf("This is also logged as INFO\n");
fprintf(stderr, "This is also logged as ERROR\n");
// Bridge is destroyed with component, streams restored
Console logging component with colored output.
Component wrapper for standard stream bridging.
Shared ownership smart pointer for interface types.
Component Configuration
<Component Id="StreamBridge" Class="ilog::CStandardStreamBridgeComp">
<Reference Id="SlaveMessageConsumer" Value="MainLog"/>
</Component>
Note
The stream buffers are restored when the component is destroyed. Ensure proper component lifecycle to avoid dangling redirections.
See also
ilog::CStandardStreamBridge, ilog::IMessageConsumer

Definition at line 73 of file CStandardStreamBridgeComp.h.

Member Typedef Documentation

◆ BaseClass

Base class typedef.

Definition at line 77 of file CStandardStreamBridgeComp.h.

Member Function Documentation

◆ OnComponentCreated()

virtual void ilog::CStandardStreamBridgeComp::OnComponentCreated ( )
overrideprotectedvirtual

Reimplemented from icomp::CComponentBase.

◆ OnComponentDestroyed()

virtual void ilog::CStandardStreamBridgeComp::OnComponentDestroyed ( )
overrideprotectedvirtual

Reimplemented from icomp::CComponentBase.


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