sk namespace
Contents
- Reference
All Skribble functionality is implemented in this namespace.
Namespaces
Classes
- class AbstractNetwork
- Contains all common events for a client/server.
- class BrushMode
- Implements drawing with a brush.
-
template<typename T, typename Traits = ResourceTraits<T>>class CachedResource
- Another utility that can manage undo/redo.
- class Canvas
- The class where all the magic happens.
- class Client
- Implements AbstractNetwork for a client.
- class DrawHistory
- A manager that correctly stores history about modifications to a canvas, even if multiple users are drawing.
- class DrawMode
- Defines methods for drawing with different instruments.
- class DummyNetwork
- Implement AbstractNetwork for single-user mode.
-
template<typename T, typename Traits = FResTraits<T>>class FCachedResource
- Class that manages undo/redo.
-
template<typename T>struct FResTraits
- Parameters for FCachedResource.
- class NetworkFactory
- Helper implementing Factory design pattern.
- class PenMode
- Implements drawing with a pen.
-
template<typename T>struct ResourceTraits
- Parameters for CachedResource.
- class Server
- Implements AbstractNetwork for a server.
Enums
- enum class Operation { UNDO, REDO, DRAW_AT, MOUSE_RELEASED, CHANGE_COLOR, CHANGE_WIDTH, TO_BRUSH, TO_PEN, NONE }
- Possible kinds of messages to be sent over the network.
- enum class NetworkModes { SINGLE_USER, CLIENT, SERVER }
- Connection type.
Functions
Variables
- int port constexpr
- Communication port used by Skribble clients/servers.
- QString host_ip
- Stores the ip to connect to.
- NetworkModes networkMode
- Stores the connection mode the user has requested.
Function documentation
template<std::size_t N, typename... Ts>
auto sk:: format(char const (&fmt)[N],
Ts && ... args) -> std::string
Helper to format strings sanely.
Inspired by python's print("{} {} {}", ...)
.
You can use it like this: sk::format("%1 %2 %1", "abra", "cad"); // returns "abracadabra"
Being equivalent to: "{0} {1} {0}".format("abra", "cad")
This function is quite an abuse of templates and fold expressions :D
auto sk:: parse(std::string const& msg) -> std::tuple< Operation, int, int, int, int >
Helper to parse messages received over the network.
Returns | { kind, a, b, c, d } |
---|
The structure of a message is kind a b c d
, where:
kind
cand be one of 'u' - undo, 'r' - redo, 'd' - draw_at, 'm' - mouse released, 'c' - change color, 'w' - change width, 'b' - to brush, 'p' - to pena
is an integer used by 'w', 'd', 'c'b
is an integer used by 'd', 'c'c
andd
are only used by 'c'
Variable documentation
QString sk:: host_ip
Stores the ip to connect to.