Locus No Pilotus
Project of four first grade MIPT DAFE/RSE students (for engineering practical work in the second semester) in Qt C++
Loading...
Searching...
No Matches
trappy_line.h
Go to the documentation of this file.
1#pragma once
2
3// std libs:
4#include <utility> // for pair
5
6// our code libs:
7#include "base.h"
8#include "target.h"
9
10namespace lib {
11
12/// @brief Линия опасного перелета
13class TrappyLine : public JSONable {
14 public:
15 TrappyLine() = default;
16
17 TrappyLine(Target* first_target, Target* second_target)
18 : targets_{std::make_pair(first_target, second_target)} {}
19 TrappyLine(std::pair<Target*, Target*> targets) : targets_{targets} {}
20
21 TrappyLine(const TrappyLine&) = default;
22 TrappyLine(TrappyLine&&) = default;
23
24 TrappyLine& operator=(const TrappyLine&) = default;
26
27 QJsonObject GetJsonInfo() const override;
28 void SetJsonInfo(const QJsonObject&) override {}
29 bool IsChanged(const QJsonObject& trappy_line_obj) const override;
30
31 void SetTargets(Target* first_target, Target* second_target) {
32 targets_ = std::make_pair(first_target, second_target);
33 }
34 void SetTargets(std::pair<Target*, Target*> targets) { targets_ = targets; }
35
36 std::pair<Target, Target> GetTargets() const;
37
38 std::pair<Target*, Target*>& GetTargetsPtrs() { return targets_; }
39 const std::pair<Target*, Target*>& GetTargetsPtrs() const { return targets_; }
40
41 bool operator==(const TrappyLine&) const;
42
43 private:
44 /// @throw td::runtime_error: класс не содержит проверяемых данных
45 void CheckErrorValues() const override {
46 throw std::runtime_error("dev: no checkable error values in TrappyLines");
47 }
48
49 // здесь нет смысла использовать умные указатели, так как мы не создаём новых
50 std::pair<Target*, Target*> targets_;
51};
52
53} // namespace lib
Объект, возможный к считыванию по .json файлу [абстрактный класс].
Definition base.h:15
Контрольная точка
Definition target.h:12
Линия опасного перелета
Definition trappy_line.h:13
void SetJsonInfo(const QJsonObject &) override
Definition trappy_line.h:28
TrappyLine & operator=(const TrappyLine &)=default
QJsonObject GetJsonInfo() const override
Definition trappy_line.cpp:9
TrappyLine(std::pair< Target *, Target * > targets)
Definition trappy_line.h:19
TrappyLine & operator=(TrappyLine &&)=default
std::pair< Target *, Target * > targets_
Definition trappy_line.h:50
TrappyLine()=default
bool operator==(const TrappyLine &) const
Definition trappy_line.cpp:34
void SetTargets(std::pair< Target *, Target * > targets)
Definition trappy_line.h:34
std::pair< Target, Target > GetTargets() const
Definition trappy_line.cpp:27
TrappyLine(TrappyLine &&)=default
void CheckErrorValues() const override
Definition trappy_line.h:45
void SetTargets(Target *first_target, Target *second_target)
Definition trappy_line.h:31
TrappyLine(Target *first_target, Target *second_target)
Definition trappy_line.h:17
TrappyLine(const TrappyLine &)=default
bool IsChanged(const QJsonObject &trappy_line_obj) const override
Definition trappy_line.cpp:19
const std::pair< Target *, Target * > & GetTargetsPtrs() const
Definition trappy_line.h:39
std::pair< Target *, Target * > & GetTargetsPtrs()
Definition trappy_line.h:38
Definition base.h:10