bn::camera_ptr class

std::shared_ptr like smart pointer that retains shared ownership of a camera.

Several camera_ptr objects may own the same camera.

The camera is released when the last remaining camera_ptr owning it is destroyed.

Public static functions

static auto create() -> camera_ptr
Creates a camera_ptr.
static auto create(fixed x, fixed y) -> camera_ptr
Creates a camera_ptr.
static auto create(const fixed_point& position) -> camera_ptr
Creates a camera_ptr.
static auto create_optional() -> optional<camera_ptr>
Creates a camera_ptr.
static auto create_optional(fixed x, fixed y) -> optional<camera_ptr>
Creates a camera_ptr.
static auto create_optional(const fixed_point& position) -> optional<camera_ptr>
Creates a camera_ptr.

Constructors, destructors, conversion operators

camera_ptr(const camera_ptr& other)
Copy constructor.
camera_ptr(camera_ptr&& other) noexcept
Move constructor.
~camera_ptr()
Releases the referenced camera if no more camera_ptr objects reference to it.

Public functions

auto operator=(const camera_ptr& other) -> camera_ptr&
Copy assignment operator.
auto operator=(camera_ptr&& other) -> camera_ptr& noexcept
Move assignment operator.
auto id() const -> int
Returns the internal id.
auto x() const -> fixed
Returns the horizontal position of the camera.
void set_x(fixed x)
Sets the horizontal position of the camera.
auto y() const -> fixed
Returns the vertical position of the camera.
void set_y(fixed y)
Sets the vertical position of the camera.
auto position() const -> const fixed_point&
Returns the position of the camera.
void set_position(fixed x, fixed y)
Sets the position of the camera.
void set_position(const fixed_point& position)
Sets the position of the camera.
void swap(camera_ptr& other)
Exchanges the contents of this camera_ptr with those of the other one.

Friends

void swap(camera_ptr& a, camera_ptr& b)
Exchanges the contents of a camera_ptr with those of another one.
auto operator==(const camera_ptr& a, const camera_ptr& b) -> bool defaulted
Default equal operator.

Function documentation

static camera_ptr bn::camera_ptr::create()

Creates a camera_ptr.

Returns The requested camera_ptr.

static camera_ptr bn::camera_ptr::create(fixed x, fixed y)

Creates a camera_ptr.

Parameters
x Horizontal position of the camera.
y Vertical position of the camera.
Returns The requested camera_ptr.

static camera_ptr bn::camera_ptr::create(const fixed_point& position)

Creates a camera_ptr.

Parameters
position Position of the camera.
Returns The requested camera_ptr.

static optional<camera_ptr> bn::camera_ptr::create_optional()

Creates a camera_ptr.

Returns The requested camera_ptr if it could be allocated; bn::nullopt otherwise.

static optional<camera_ptr> bn::camera_ptr::create_optional(fixed x, fixed y)

Creates a camera_ptr.

Parameters
x Horizontal position of the camera.
y Vertical position of the camera.
Returns The requested camera_ptr if it could be allocated; bn::nullopt otherwise.

static optional<camera_ptr> bn::camera_ptr::create_optional(const fixed_point& position)

Creates a camera_ptr.

Parameters
position Position of the camera.
Returns The requested camera_ptr if it could be allocated; bn::nullopt otherwise.

bn::camera_ptr::camera_ptr(const camera_ptr& other)

Copy constructor.

Parameters
other camera_ptr to copy.

bn::camera_ptr::camera_ptr(camera_ptr&& other) noexcept

Move constructor.

Parameters
other camera_ptr to move.

camera_ptr& bn::camera_ptr::operator=(const camera_ptr& other)

Copy assignment operator.

Parameters
other camera_ptr to copy.
Returns Reference to this.

camera_ptr& bn::camera_ptr::operator=(camera_ptr&& other) noexcept

Move assignment operator.

Parameters
other camera_ptr to move.
Returns Reference to this.

void bn::camera_ptr::set_position(fixed x, fixed y)

Sets the position of the camera.

Parameters
x Horizontal position of the camera.
y Vertical position of the camera.

void bn::camera_ptr::swap(camera_ptr& other)

Exchanges the contents of this camera_ptr with those of the other one.

Parameters
other camera_ptr to exchange the contents with.

void swap(camera_ptr& a, camera_ptr& b)

Exchanges the contents of a camera_ptr with those of another one.

Parameters
a First camera_ptr to exchange the contents with.
b Second camera_ptr to exchange the contents with.