ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

57 lines
1.2 KiB

  1. #ifndef CPPCMS_VIEWS_POOL_H
  2. #define CPPCMS_VIEWS_POOL_H
  3. #include "defs.h"
  4. #include "noncopyable.h"
  5. #include "base_view.h"
  6. #include <memory>
  7. #include <map>
  8. #include <ostream>
  9. namespace cppcms {
  10. namespace json { class value; }
  11. class CPPCMS_API views_pool : public util::noncopyable {
  12. public:
  13. typedef std::auto_ptr<base_view> (*view_factory_type)(std::ostream &,base_content *c);
  14. typedef std::map<std::string,view_factory_type> mapping_type;
  15. template<typename View,typename Content>
  16. static std::auto_ptr<base_view> view_builder(std::ostream &stream,base_content *c)
  17. {
  18. std::auto_ptr<base_view> p(new View(stream,dynamic_cast<Content &>(*c)));
  19. return p;
  20. };
  21. views_pool();
  22. views_pool(json::value const &settings);
  23. ~views_pool();
  24. ///
  25. /// Thread safe member function
  26. ///
  27. void render(std::string skin,std::string template_name,std::ostream &out,base_content &content);
  28. ///
  29. /// Get default skin name
  30. ///
  31. std::string default_skin() const;
  32. void add_view(std::string skin,mapping_type const &mapping);
  33. void remove_view(std::string skin);
  34. static views_pool &static_instance();
  35. private:
  36. struct data;
  37. struct skin;
  38. util::hold_ptr<data> d;
  39. };
  40. }
  41. #endif