Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component balb_filecleanerconfiguration
[Package balb]

Provide an attribute class for file cleaner configuration. More...

Namespaces

namespace  balb

Detailed Description

Outline
Purpose:
Provide an attribute class for file cleaner configuration.
Classes:
balb::FileCleanerConfiguration configuration spec for a file cleaner
See also:
Component 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]
  • filePattern: filesystem pattern used for file matching.
  • maxFileAge : maximum file age (since last modification).
  • minNumFiles: minumum number of (newest) files, matching the pattern, that must be kept by the file cleaner.
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: Next, we populate the attributes of our configuration object:
  config.setFilePattern("/var/log/myApp/log*");
  config.setMaxFileAge(bsls::TimeInterval(60*60*24));
  config.setMinFilesNumber(4);
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());
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
  ]