Design Pattern Examples
Overview of object-oriented design patterns
cplusplus/Composite_FileAccess.h
Go to the documentation of this file.
1
5
6#pragma once
7#ifndef __COMPOSITE_FILEACCESS_H__
8#define __COMPOSITE_FILEACCESS_H__
9
10#include <memory>
12
14{
15
20 // Using a class here instead of a namespace because Doxygen seems to have
21 // trouble with nested namespaces.
23 {
24 private:
29 static std::shared_ptr<FileDirEntry> rootEntry;
30
38 static FileDirEntry* _FindEntry(std::string filepath);
39
40 public:
51 static FileDirEntry* GetEntry(std::string filepath);
52 };
53} // end namespace
54
55#endif // __COMPOSITE_FILEACCESS_H__
56
Class containing static functions for accessing a hardcoded "file" and "directory" hierarchy.
static FileDirEntry * _FindEntry(std::string filepath)
Helper method to search the static data list for the specified file/dir entry.
static std::shared_ptr< FileDirEntry > rootEntry
List of all "files" and "directories" used in the Command Pattern example.
static FileDirEntry * GetEntry(std::string filepath)
Return a FileDirEntry object representing the specified file "path" in an internal list of data entri...
Base class representing a File or Directory entry.
Implementation of the FileDirEntry, FileEntry, and DirEntry classes used in the Composite Pattern.
The namespace containing all Design Pattern Examples implemented in C++.