bwidgets/inc/basic_widgets/w/widget_factory.hpp
Andrea Blankenstijn a19d2ea6bd - mark as const every single read only variable.
- mark as const every pointer that can be const.
- in implementation mark const args passed by value that are meant to be read-only.
- wrap in a lambda complex initializations of (const) values.
- argument passing:
  - pass by value arguments of cheap-to-copy types or meant to be copied
    anyway.
  - pass by (const) reference args not meant to outlive called
    function scope and not cheap-to-copy.
  - pass (const) pointers to (const) args when null is a valid option
    and pointed data aren't expected to outlive function scope.
  - use string_view for non-owned strings (not meant to outlive function
    scope).
  - use span for collection types like vector and arrays.
  - fancy pointers passing:
    - pass by value if a reference will be held:
    - pass by const reference if a reference _may_ be hell.
    - when no references are meant to be held:
        - dereference the pointer to pass the pointed data by reference
          if null is not an option.
        - pass the underlying raw pointer if null is an option.
… and random subtle changes and fixes here and there that I forgot to mention.
2021-08-22 00:57:55 +02:00

20 lines
773 B
C++

#ifndef BWIDGETS_WIDGET_FACTORY_HPP
#define BWIDGETS_WIDGET_FACTORY_HPP
#include <basic_widgets/w/aligned_layout.hpp>
#include <basic_widgets/w/button.hpp>
#include <basic_widgets/w/caption.hpp>
#include <basic_widgets/w/numeric_input.hpp>
namespace bwidgets
{
auto create_button(Widget* p = nullptr) -> std::unique_ptr<Button>;
auto create_caption(Widget* p = nullptr) -> std::unique_ptr<Caption>;
auto create_horizontal_layout(Widget* p = nullptr) -> std::unique_ptr<AlignedLayout>;
auto create_input_float(Widget* p = nullptr) -> std::unique_ptr<NumericInput<float>>;
auto create_input_int(Widget* p = nullptr) -> std::unique_ptr<NumericInput<int>>;
auto create_vertical_layout(Widget* p = nullptr) -> std::unique_ptr<AlignedLayout>;
}
#endif