BDE 4.14.0 Production release
Loading...
Searching...
No Matches
balb_filecleanerconfiguration

Detailed Description

Outline

Purpose

Provide an attribute class for file cleaner configuration.

Classes

See also
balb_filecleanerutil

Description

This component provides a single, simply constrained (value-semantic) attribute class, balb::FileCleanerConfiguration, that contains a set of attributes (objects and parameters) of a file cleaner.

Attributes

Name Type Default Simple Constraints
-------------- ------------------ -------------- ------------------
filePattern bsl::string "" none
maxFileAge bsls::TimeInterval TimeInterval() none
minNumFiles int 0 [0 .. INT_MAX]
Definition bslstl_string.h:1281
Definition bsls_timeinterval.h:301

Thread Safety

balb::FileCleanerConfiguration is const thread-safe, meaning that accessors may be invoked concurrently from different threads, but it is not safe to access or modify a balb::FileCleanerConfiguration in one thread while another thread modifies the same object.

Usage

This section illustrates intended use of this component.

Example 1: Basic Usage

The following code illustrates how to create a configuration that can be later supplied to a file cleanup utility (see balb_filecleanerutil for an example of how to use the created configuration to perform file cleaning).

First, we create a balb::FileCleanerConfiguration object having the default value:

Definition balb_filecleanerconfiguration.h:161

Next, we populate the attributes of our configuration object:

config.setFilePattern("/var/log/myApp/log*");
config.setMinFilesNumber(4);
void setFilePattern(const bsl::string_view &filePattern)
Definition balb_filecleanerconfiguration.h:330
void setMaxFileAge(const bsls::TimeInterval &maxAge)
Definition balb_filecleanerconfiguration.h:337

Now, we verify the options are configured correctly:

assert("/var/log/myApp/log*" == config.filePattern());
assert(bsls::TimeInterval(60*60*24) == config.maxFileAge());
assert(4 == config.minNumFiles());
const bsl::string & filePattern() const
Definition balb_filecleanerconfiguration.h:351
int minNumFiles() const
Return the minimum number of files to keep attribute of this object.
Definition balb_filecleanerconfiguration.h:363
bsls::TimeInterval maxFileAge() const
Return the maximum file age attribute of this object.
Definition balb_filecleanerconfiguration.h:357

Finally, we print the configuration value to cout and return:

bsl::cout << config << bsl::endl;

This produces the following (multi-line) output:

[
FilePattern = /var/log/myApp/log*
MaxFileAge = (86400, 0)
MinNumFiles = 4
]