Design Pattern Examples
Overview of object-oriented design patterns
DirEntry Class Reference

Represents a Directory entry. More...

#include <Composite_FileDirEntry.h>

Inheritance diagram for DirEntry:
Inheritance graph
Collaboration diagram for DirEntry:
Collaboration graph

Public Member Functions

 DirEntry (std::string entryName, DateTime modDate, FileDirEntryList children)
 Construct a DirEntry instance.
 
long Length ()
 Retrieve the size of all children of this directory. The length is calculated on the first call and cached for subsequent calls.
 
FileDirEntryList Children ()
 Retrieve the children of this node.
 
- Public Member Functions inherited from FileDirEntry
 FileDirEntry ()
 Default constructor.
 
 FileDirEntry (FileDirTypes type, std::string entryName, long size, DateTime modDate)
 Constructor.
 
virtual FileDirTypes FileDirType ()
 The type of this entry as represented by a value from the FileDirTypes enumeration.
 
virtual std::string Name ()
 The name of this entry.
 
virtual long Length ()
 The length in bytes of this entry. Directory entries are the sum of the length of all children.
 
virtual DateTime WhenModified ()
 When this entry was last modified.
 
virtual FileDirEntryList Children ()
 The children of this entry. Is empty if the entry can never have any children (that is, it isn't a container of other entries).
 

Public Attributes

FileDirEntryList _children
 
bool _lengthSet
 

Additional Inherited Members

- Protected Attributes inherited from FileDirEntry
FileDirTypes fileDirType
 
std::string name
 
long length
 
DateTime whenModified
 

Detailed Description

Represents a Directory entry.

A directory entry contains 0 or more children, which can be a mix of file and directory entries.

A Directory's size is the sum of all children sizes.

Definition at line 149 of file cplusplus/Composite_FileDirEntry.h.

Constructor & Destructor Documentation

◆ DirEntry()

DirEntry ( std::string  entryName,
DateTime  modDate,
FileDirEntryList  children 
)
inline

Construct a DirEntry instance.

Parameters
entryNameName of the directory
modDatemodification date time of the entry
childrenArray of children. Can be empty.

Definition at line 161 of file cplusplus/Composite_FileDirEntry.h.

Member Function Documentation

◆ Children()

FileDirEntryList Children ( )
inlinevirtual

Retrieve the children of this node.

This is an override of the base class and uses a collection of children entries stored in the DirEntry class so the base class doesn't need to store it.

Reimplemented from FileDirEntry.

Definition at line 199 of file cplusplus/Composite_FileDirEntry.h.

References DirEntry::_children.

◆ Length()

long Length ( )
inlinevirtual

Retrieve the size of all children of this directory. The length is calculated on the first call and cached for subsequent calls.

This is an override of the base class to provide different behavior.

Reimplemented from FileDirEntry.

Definition at line 175 of file cplusplus/Composite_FileDirEntry.h.

References DirEntry::_children, DirEntry::_lengthSet, and FileDirEntry::length.

Member Data Documentation

◆ _children

FileDirEntryList _children

Definition at line 152 of file cplusplus/Composite_FileDirEntry.h.

Referenced by DirEntry::Children(), and DirEntry::Length().

◆ _lengthSet

bool _lengthSet

Definition at line 153 of file cplusplus/Composite_FileDirEntry.h.

Referenced by DirEntry::Length().


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