Skip to content

📌 Simple and lightweight factory class, featuring automatic type casting. Written in C++11

License

Notifications You must be signed in to change notification settings

r-lyeh-archived/memo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

memo

  • Memo is a simple and lightweight factory class, written in C++11.
  • Memo is an abstract factory class, designed mainly for resource handling.
  • Memo is automatic type casting. Store resources of any kind in the very same factory.
  • Memo is deterministic lifetime of objects, that get destroyed when factory is destroyed.
  • Memo is cross-platform. Builds on Windows/Linux/MacosX. Compiles on g++/clang/msvc.
  • Memo is tiny, header-only, self-contained.
  • Memo is zlib/libpng licensed.

sample

    // abstract factory: locate items by string id
    memo::factory< std::string > factory;

    // inscribe items of any kind (textures, anims, maps, texts...)
    factory["numbers"] = std::vector<int>( {1,2,3,4,5} );
    factory["names"] = std::list<std::string>( {"john", "mark", "tony"} );

    // clone items (implicit casting)
    std::vector<int> numbers = factory["numbers"];

    // clone items (explicit casting)
    std::list<std::string> names = factory["names"].as< std::list<std::string> >();

    // tests
    assert( 5 == numbers.size() );
    assert( 3 == names.size() );

    // delete items on factory destruction

Check sample.cc for detailed usage.

About

📌 Simple and lightweight factory class, featuring automatic type casting. Written in C++11

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages