Reliable Transaction Router
C++ Foundation Classes


Previous Contents Index


Increment()


RTRSignedCounter::Increment();


Prototype


rtr_status_t Increment(); 


Return Value

rtr_status_t Interpret value for the success or failure of this call.
Status Message
RTR_STS_CTRBADOPER The supplied argument specifies an illegal counter operation.
RTR_STS_CTRBADREF The supplied argument does not reference a valid counter.
RTR_STS_INVOBJFAILCNSTR Invalid object due to failure during object construction.
RTR_STS_OK Normal successful completion

The more specific counter class error status descriptions for RTR_STSCTRBADREF and RTR_STS_INVOBJFAILCNSTR are:


Parameters

None

Description

Call this method to increment a numeric counter. This method can be called only after setting value.

Example


rtr_const_countername_t kCounter = "test-counter-signed-increment"; 
rtr_const_countergroupname_t kGroup = "test-counter-group"; 
 
RTRSignedCounter c(kCounter, kGroup); 
rtr_sgn_32_t v = 0; 
const rtr_sgn_32_t kValue = 668; 
bool bOverallResult = true; 
 
rtr_status_t stsSetValue; 
stsSetValue = c.SetValue(kValue); 
if (IsFailure(stsSetValue == RTR_STS_OK)) 
{ 
bOverallResult = false; 
OutputStatus(stsSetValue); 
} 
 
rtr_status_t stsIncrement; 
stsIncrement = c.Increment(); 
if (IsFailure(stsIncrement == RTR_STS_OK)) 
{ 
bOverallResult = false; 
OutputStatus(stsIncrement); 
} 
 


SetValue()


RTRSignedCounter::SetValue();


Prototype


rtr_status_t SetValue( rtr_sgn_32_t CounterVal ); 
 


Return Value

rtr_status_t Interpret value for the success or failure of this call.
Status Message
RTR_STS_OK Normal successful completion
RTR_STS_INVOBJFAILCNSTR Invalid object due to failure during object construction.

The more specific counter class error status description for RTR_STS_INVOBJFAILCNSTR is:

The object is invalid because the values passed in the constructor were invalid.


Parameters

CounterVal

A counter value for a specified RTR counter.

Description

Call this method to set value for a counter. Object should be declared before setting value.

Example


rtr_status_t sStatus; 
int iSetValue = 100; 
sStatus = IIntCounter->SetValue(iSetValue); 
 


RTRSignedCounter()


RTRSignedCounter::RTRSignedCounter();


Prototype


RTRSignedCounter( rtr_const_countername_t pszCounterName , 
                  rtr_const_countergroupname_t pszCounterGroupName); 


Return Value

None

Parameters

pszCounterName

A null-terminated string pointer to the name of an RTR counter.

pszCounterGroupName

A null-terminated string pointer to the name of an RTR counter group.

Description

This method used to declare an RTRSignedCounter object. The constructor creates an instance of the RTRSignedCounter class. The application must call SetValue() to initialize the counter.

All counters are process-specific. All counter names must be unique within the entire process without regard to the group name. For example, it is invalid to have an RTRSignedCounter name "MyCounter" and another RTRStringCounter name "MyCounter."


Example


rtr_counter_data_type eCtrtype  = rtr_counter_int; 
RTRSignedCounter *iIntCounter = new 
             RTRSignedCounter("MyCounter3","GroupName",eCtrtype); 

4.11 RTRStringCounter

To use a counter, perform the following steps:

RTRStringCounter Class Members

Construction
Method Description
RTRStringCounter( const char, const char, rtr_counter_data_type) Constructor
~RTRStringCounter() Destructor

Operations
Method Description
GetValue(char) Retrieve the value managed by the counter class.
SetValue(const char) Set the value managed by the counter class.


GetValue()


RTRStringCounter::GetValue();


Prototype


rtr_status_t GetValue(char * pszCounterVal); 


Return Value

rtr_status_t Interpret value for the success or failure of this call.
Status Message
RTR_STS_CTRBADREF The supplied argument does not reference a valid counter.
RTR_STS_INVOBJFAILCNSTR Invalid object due to failure during object construction.
RTR_STS_OK Normal successful completion

The more specific counter class error status descriptions for RTR_STSCTRBADREF and RTR_STS_INVOBJFAILCNSTR are:


Parameters

pszCounterVal

A null-terminated string pointer to the name of an RTR counter.

Description

Call this method to get a counter value. GetValue can be called only after setting a value (SetValue).

Example


int IIntCounter; 
rtr_status_t sStatus; 
sStatus = cMyCounter.GetValue(IIntCounter); 
if (sStatus!= RTR_STS_OK) cerr<<"Error while getting counter value"; 


SetValue()


RTRStringCounter::SetValue();


Prototype


rtr_status_t SetValue(const char * pszCounterVal); 
 


Return Value

rtr_status_t Interpret value for the success or failure of this call.
Status Message
RTR_STS_OK Normal successful completion
RTR_STS_INVOBJFAILCNSTR Invalid object due to failure during object construction.

The more specific counter class error status description for RTR_STS_INVOBJFAILCNSTR is:

The object is invalid because the values passed in the constructor were invalid.


Parameters

pszCounterVal

A null-terminated string pointer to the value of an RTR counter.

Description

Call this method to set a counter value.

Example


rtr_status_t sStatus; 
int iSetValue = 100; 
sStatus = IIntCounter->SetValue(iSetValue); 


RTRStringCounter()


RTRStringCounter::RTRStringCounter();


Prototype


RTRStringCounter(const char *pszCounterName , 
                 const char *pszCounterGroupName); 


Return Value

None

Parameters

pszCounterName

A null-terminated string pointer to the name of an RTR counter.

pszCounterGroupName

A null-terminated string pointer to the name of an RTR counter group.

Description

This method used to declare an RTRStringCounter object. The constructor creates an instance of the RTRStringCounter class. The application must call SetValue() to initialize the counter.

All counters are process-specific. All counter names must be unique within the entire process without regard to the group name. For example, it is invalid to have an RTRStringCounter name "MyCounter" and another RTRSignedCounter name "MyCounter."


Example


rtr_counter_data_type eCtrtype  = rtr_counter_int; 
 
RTRStringCounter *iIntCounter = new 
      RTRStringCounter("MyCounter2","GroupName",eCtrtype); 

4.12 RTRUnsignedCounter

To use a counter, perform the following steps:

RTRUnsignedCounter Class Members

Construction
Method Description
RTRUnsignedCounter( rtr_const_countername_t, rtr_const_countergroupname_t) Constructor
~RTRUnsignedCounter() Destructor


 

Operations
Method Description
Decrement() Decrement the value managed by the counter class.
GetValue(rtr_uns_32_t) Retrieve the value managed by the counter class.
Increment() Increment the value managed by the counter class.
SetValue(rtr_uns_32_t) Set the value managed by the counter class.


Decrement()


RTRUnsignedCounter::Decrement();


Prototype


rtr_status_t Decrement(); 


Return Value

rtr_status_t Interpret value for the success or failure of this call.
Status Message
RTR_STS_CTRBADOPER The supplied argument specifies an illegal counter operation.
RTR_STS_CTRBADREF The supplied argument does not reference a valid counter.
RTR_STS_INVOBJFAILCNSTR Invalid object due to failure during object construction.
RTR_STS_OK Normal successful completion

The more specific counter class error status descriptions for RTR_STSCTRBADREF and RTR_STS_INVOBJFAILCNSTR are:


Parameters

None

Description

Call this method to decrement a numeric counter. Decrement method can be called only after setting value.

Example


RTRUnsignedCounter c(kCounter, kGroup); 
rtr_uns_32_t v = 0; 
const rtr_uns_32_t kValue = 669; 
bool bOverallResult = true; 
 
rtr_status_t stsSetValue; 
stsSetValue = c.SetValue(kValue); 
if (IsFailure(stsSetValue == RTR_STS_OK)) 
{ 
bOverallResult = false; 
OutputStatus(stsSetValue); 
} 
 
rtr_status_t stsDecrement; 
stsDecrement = c.Decrement(); 
if (IsFailure(stsDecrement == RTR_STS_OK)) 
{ 
bOverallResult = false; 
OutputStatus(stsDecrement); 
} 


GetValue()


RTRUnsignedCounter::GetValue();


Prototype


rtr_status_t GetValue(rtr_uns_32_t &CounterVal); 
 


Return Value

rtr_status_t Interpret value for the success or failure of this call.
Status Message
RTR_STS_CTRBADREF The supplied argument does not reference a valid counter.
RTR_STS_INVOBJFAILCNSTR Invalid object due to failure during object construction.
RTR_STS_OK Normal successful completion.

The more specific counter class error status descriptions for RTR_STSCTRBADREF and RTR_STS_INVOBJFAILCNSTR are:


Parameters

CounterVal

A counter value for a specified RTR counter.

Description

Call this method to get a counter value. GetValue can be called only after setting value (SetValue).

Example


rtr_status_t sStatus; 
sStatus = IIntCounter->GetValue(iReturnValue); 
 


Increment()


RTRUnsignedCounter::Increment();


Prototype


rtr_status_t Increment(); 
 


Return Value

rtr_status_t Interpret value for the success or failure of this call.
Status Message
RTR_STS_CTRBADOPER The supplied argument specifies an illegal counter operation for the counter type.
RTR_STS_CTRBADREF The supplied argument does not reference a valid counter.
RTR_STS_INVOBJFAILCNSTR Invalid object due to failure during object construction.
RTR_STS_OK Normal successful completion

The more specific counter class error status descriptions for RTR_STSCTRBADREF and RTR_STS_INVOBJFAILCNSTR are:

RTR_STSCTRBADREF

The object has not been initialized by the application. All counters must be given a default value by calling SetValue() after object construction.

RTR_STS_INVOBJFAILCNSTR

The object is invalid because the values passed in the constructor were invalid.


Parameters

None

Description

Call this method to increment a numeric counter. This method can be called only after setting value.

Example


rtr_status_t stsIncrement; 
stsIncrement = c.Increment(); 
if (IsFailure(stsIncrement == RTR_STS_OK)) 
{ 
bOverallResult = false; 
OutputStatus(stsIncrement); 
} 


SetValue()


RTRUnsignedCounter::SetValue();


Prototype


rtr_status_t SetValue( rtr_uns_32_t CounterVal ); 


Return Value

rtr_status_t Interpret value for the success or failure of this call.
Status Message
RTR_STS_OK Normal successful completion
RTR_STS_INVOBJFAILCNSTR Invalid object due to failure during object construction.

The more specific counter class error status description for RTR_STS_INVOBJFAILCNSTR is:

The object is invalid because the values passed in the constructor were invalid.


Parameters

CounterVal

A counter value for a specified RTR counter.

Description

Call this method to set value for a counter. Object should be declared before setting value.

Example


rtr_status_t sStatus; 
int iSetValue = 100; 
sStatus = IIntCounter->SetValue(iSetValue); 
 


RTRUnsignedCounter()


RTRUnsignedCounter::RTRUnsignedCounter();


Prototype


RTRUnsignedCounter( rtr_const_countername_t pszCounterName , 
                    rtr_const_countergroupname_t pszCounterGroupName); 


Return Value

None

Parameters

pszCounterName

A null-terminated string pointer to the name of an RTR counter.

pszCounterGroupName

A null-terminated string pointer to the name of an RTR counter group.

Description

This method used to declare an RTRUnsignedCounter object. The constructor creates an instance of the RTRUnsignedCounter class. The application must call SetValue() to initialize the counter.

All counters are process-specific. All counter names must be unique within the entire process without regard to the group name. For example, it is invalid to have an RTRUnsignedCounter name "MyCounter" and another RTRStringCounter name "MyCounter."


Example


rtr_counter_data_type eCtrtype  = rtr_counter_int; 
RTRUnsignedCounter *iIntCounter = new 
            RTRUnsignedCounter("MyCounter1","GroupName",eCtrtype) 


Previous Next Contents Index