Skip to content

Commit

Permalink
Use forward declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
dhurum committed Nov 21, 2015
1 parent c004c12 commit 47eae18
Show file tree
Hide file tree
Showing 21 changed files with 53 additions and 19 deletions.
8 changes: 5 additions & 3 deletions src/animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ Mattext is distributed in the hope that it will be useful,
#include <unordered_map>
#include <memory>
#include <string>
#include "config.h"
#include "terminal.h"
#include "file_reader.h"
#include <list>

class Text;
class Config;
class Terminal;

class Animation {
public:
Expand Down
3 changes: 3 additions & 0 deletions src/animation_fire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Mattext is distributed in the hope that it will be useful,
*******************************************************************************/

#include "animation_fire.h"
#include "terminal.h"
#include "config.h"
#include "file_reader.h"

void FireAnimation::init() {
fire_heights.resize(terminal_width);
Expand Down
2 changes: 2 additions & 0 deletions src/animation_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Mattext is distributed in the hope that it will be useful,
*******************************************************************************/

#include "animation_generic.h"
#include "terminal.h"
#include "config.h"

GenericAnimation::GenericAnimation(const Config &config,
const Terminal &terminal)
Expand Down
5 changes: 4 additions & 1 deletion src/animation_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ Mattext is distributed in the hope that it will be useful,
*******************************************************************************/

#include "animation_matrix.h"
#include "terminal.h"
#include "config.h"
#include "file_reader.h"

void MatrixAnimation::init() {
col_lengths.resize(terminal_width);
col_offsets.resize(terminal_width);
tick_id = 0;

if (config.rand_columns_len <= 0) {
max_col_length = terminal.getHeight();
max_col_length = terminal_height;
} else {
max_col_length = config.rand_columns_len;
}
Expand Down
2 changes: 2 additions & 0 deletions src/animation_none.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Mattext is distributed in the hope that it will be useful,
*******************************************************************************/

#include "animation_none.h"
#include "terminal.h"
#include "file_reader.h"

NoneAnimation::NoneAnimation(const Terminal &terminal) : terminal(terminal) {}

Expand Down
5 changes: 4 additions & 1 deletion src/animation_reverse_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ Mattext is distributed in the hope that it will be useful,
*******************************************************************************/

#include "animation_reverse_matrix.h"
#include "terminal.h"
#include "config.h"
#include "file_reader.h"

void ReverseMatrixAnimation::tick(ev::timer &w, int revents) {
int _terminal_height = static_cast<int>(terminal_height);
bool stopped = true;

for (size_t col = 0; col < terminal.getWidth(); ++col) {
for (size_t col = 0; col < terminal_width; ++col) {
int col_start = _terminal_height - 1 - tick_id + col_offsets[col];
int col_end = col_start + col_lengths[col];
int text_start = col_end + tail_length + 1;
Expand Down
2 changes: 2 additions & 0 deletions src/file_backward_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Mattext is distributed in the hope that it will be useful,
#include <stdexcept>
#include <string.h>
#include "file_backward_reader.h"
#include "config.h"
#include "file_io.h"

BackwardReader::BackwardReader(std::vector<std::vector<wchar_t>> &lines,
std::vector<size_t> &line_lens,
Expand Down
3 changes: 2 additions & 1 deletion src/file_backward_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Mattext is distributed in the hope that it will be useful,

#include <vector>
#include "file_reader_logic.h"
#include "config.h"

class Config;

class BackwardReader : public FileReaderLogic {
public:
Expand Down
2 changes: 2 additions & 0 deletions src/file_forward_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Mattext is distributed in the hope that it will be useful,
#include <stdexcept>
#include <string.h>
#include "file_forward_reader.h"
#include "config.h"
#include "file_io.h"

ForwardReader::ForwardReader(std::vector<std::vector<wchar_t>> &lines,
std::vector<size_t> &line_lens,
Expand Down
3 changes: 2 additions & 1 deletion src/file_forward_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Mattext is distributed in the hope that it will be useful,

#include <vector>
#include "file_reader_logic.h"
#include "config.h"

class Config;

class ForwardReader : public FileReaderLogic {
public:
Expand Down
2 changes: 2 additions & 0 deletions src/file_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Mattext is distributed in the hope that it will be useful,
#include "file_reader.h"
#include "file_forward_reader.h"
#include "file_backward_reader.h"
#include "config.h"
#include "terminal.h"

FileReader::FileReader(const Config &config, const Terminal &terminal)
: terminal(terminal),
Expand Down
5 changes: 3 additions & 2 deletions src/file_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ Mattext is distributed in the hope that it will be useful,

#include <vector>
#include <memory>
#include "config.h"
#include "terminal.h"
#include "file_reader_logic.h"
#include "file_io.h"

class Terminal;
class Config;

class Text {
public:
virtual wchar_t get(size_t column, size_t row) const = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/file_reader_logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ Mattext is distributed in the hope that it will be useful,
#pragma once

#include <string>
#include "file_io.h"

class FileIO;

class FileReaderLogic {
public:
Expand Down
2 changes: 2 additions & 0 deletions src/file_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Mattext is distributed in the hope that it will be useful,
#include <unistd.h>
#include <sstream>
#include "file_stream.h"
#include "config.h"
#include "terminal.h"

FileStream::FileStream(const Config &config, const Terminal &terminal)
: config(config), terminal(terminal), file_reader(config, terminal) {
Expand Down
5 changes: 3 additions & 2 deletions src/file_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ Mattext is distributed in the hope that it will be useful,
#include <list>
#include <functional>
#include <ev++.h>
#include "config.h"
#include "terminal.h"
#include "file_reader.h"
#include "file_io.h"

class Terminal;
class Config;

class FileStream {
public:
FileStream(const Config &config, const Terminal &terminal);
Expand Down
3 changes: 3 additions & 0 deletions src/manager_interactive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Mattext is distributed in the hope that it will be useful,
#include <ev++.h>
#include <ncurses.h>
#include "manager_interactive.h"
#include "config.h"
#include "file_stream.h"
#include "terminal.h"

ManagerInteractive::ManagerInteractive(const Config &config,
FileStream &file_stream,
Expand Down
7 changes: 4 additions & 3 deletions src/manager_interactive.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ Mattext is distributed in the hope that it will be useful,

#pragma once

#include "config.h"
#include "file_stream.h"
#include "terminal.h"
#include "animation.h"
#include "manager.h"

class Config;
class Terminal;
class FileStream;

class ManagerInteractive : public Manager {
public:
ManagerInteractive(const Config &config, FileStream &file_stream,
Expand Down
1 change: 1 addition & 0 deletions src/manager_plain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Mattext is distributed in the hope that it will be useful,
#include <ev++.h>
#include <string.h>
#include "manager_plain.h"
#include "file_stream.h"

ManagerPlain::ManagerPlain(FileStream &file_stream) : file_stream(file_stream) {
read();
Expand Down
5 changes: 2 additions & 3 deletions src/manager_plain.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ Mattext is distributed in the hope that it will be useful,

#pragma once

#include "config.h"
#include "file_stream.h"
#include "terminal.h"
#include "manager.h"

class FileStream;

class ManagerPlain : public Manager {
public:
ManagerPlain(FileStream &file_stream);
Expand Down
1 change: 1 addition & 0 deletions src/terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Mattext is distributed in the hope that it will be useful,
#include <string.h>
#include <fcntl.h>
#include "terminal.h"
#include "config.h"

Terminal::Terminal(const Config &config)
: colors{COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW,
Expand Down
3 changes: 2 additions & 1 deletion src/terminal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Mattext is distributed in the hope that it will be useful,
#include <functional>
#include <unistd.h>
#include <ev++.h>
#include "config.h"

class Config;

enum Colors {
ColorDefault = -1,
Expand Down

0 comments on commit 47eae18

Please sign in to comment.