This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FilesPurger { | |
| public: | |
| virtual ~FilesPurger(); | |
| virtual void purge(const std::string &root) = 0; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DiskJanitor { | |
| private: | |
| std::unique_ptr<FilesPurger> _purger; | |
| public: | |
| DiskJanitor(std::unique_ptr<FilesPurger> purger); | |
| void clean_files(const std::string &root); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TextData { | |
| private: | |
| std::string _data; | |
| std::unique_ptr<SpellChecker> _spell_checker; | |
| std::unique_ptr<StorageManager> _storage_manager; | |
| ... | |
| public: | |
| int save(const std::string &loc, | |
| const TextData &text_data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class StorageManager { | |
| virtual int save(const std::string &loc, | |
| const TextData &text_data) = 0; | |
| }; | |
| class TextFileStorageManager : public StorageManager { | |
| int save(const std::string &loc, | |
| const TextData &text_data); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TextData text_data("Some data.", | |
| std::unique_ptr<SpellChecker>(new SpellChecker()) | |
| ); | |
| text_data.spell_check(); | |
| text_data.set_spell_checker( | |
| std::unique_ptr<SpellChecker>(new AdvancedSpellChecker()) | |
| ); | |
| text_data.spell_check(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AdvancedSpellChecker : public SpellChecker { | |
| std::vector<std::string> spell_check(const std::string &data); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TextData { | |
| private: | |
| std::string _data; | |
| std::unique_ptr<SpellChecker> _spell_checker; | |
| public: | |
| TextData(const std::string &s, | |
| std::unique_ptr<SpellChecker> sc); | |
| TextData(const TextData &other); | |
| TextData& operator=(const TextData &other); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SpellChecker { | |
| private: | |
| std::set<std::string> _dict; | |
| public: | |
| SpellChecker(); | |
| virtual ~SpellChecker(); | |
| virtual std::vector<std::string> spell_check(const std::string &data); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TextData { | |
| private: | |
| std::string _data; | |
| public: | |
| // Methods | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| std::unique_ptr<File> home( | |
| std::make_unique<DirectoryFile>("/users/raj", 700) | |
| ); | |
| std::unique_ptr<File> f1( | |
| std::make_unique<RegularFile>("file1", 644) | |
| ); | |
| std::unique_ptr<File> f2( | |
| std::make_unique<RegularFile>("file2", 644) | |
| ); |