diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..4da60d8fe93a9d0075cf506d78becd72fc55ffad --- /dev/null +++ b/Makefile @@ -0,0 +1,51 @@ +# Makefile Bar Chart Race + +# Project Name +PROJ_NAME = bcr + +# Sources files (*.cpp) +CPP_SOURCE = $(wildcard ./src/*.cpp) + +# Header files (*.h) +H_SOURCE = $(wildcard ./lib/*h) + +# Objects files +OBJ_FILE = $(subst .cpp,.o, $(subst src,bin,$(CPP_SOURCE))) + +# Compiler +CC = g++ + +# Flags for Compiler +CC_FLAGS = -c \ + -Wall \ + -std=c++11 + +# Remove Command +RM = rm -rf + +# Commands + +all: objFolder $(PROJ_NAME) + +$(PROJ_NAME): $(OBJ_FILE) ./bin/main.o + @ echo 'Building executable file: $@. Compiler: $(CC)' + $(CC) -o $@ $^ + @ echo ' ' + @ echo 'To run the program use ./$(PROJ_NAME)' + +./bin/%.o: ./src/%.cpp ./lib/%.h + @ echo 'Building $<. Compiler $(CC)' + $(CC) $< $(CC_FLAGS) -o $@ + @ echo ' ' + +./bin/main.o: main.cpp $(OBJ_FILE) + @ echo 'Building $<. Compiler: $(CC)' + $(CC) $< $(CC_FLAGS) -o $@ + @ echo ' ' + +objFolder: + @ mkdir -p bin + +clean: + @ $(RM) ./bin/* + @ rmdir bin diff --git a/bcr b/bcr new file mode 100755 index 0000000000000000000000000000000000000000..0bd9c033ab1e34507508ba8e5ae208b14f998545 Binary files /dev/null and b/bcr differ diff --git a/bin/bcr.o b/bin/bcr.o new file mode 100644 index 0000000000000000000000000000000000000000..9cefc40fb8670fbe9a3ba0826fd334ac001c9251 Binary files /dev/null and b/bin/bcr.o differ diff --git a/bin/main.o b/bin/main.o new file mode 100644 index 0000000000000000000000000000000000000000..8d8bb300185995f913eeb93e70c8b19c46e718f4 Binary files /dev/null and b/bin/main.o differ diff --git a/data/teste.txt b/data/teste.txt new file mode 100644 index 0000000000000000000000000000000000000000..96beb6afe20619a03ab13078e3251d0fb595be20 --- /dev/null +++ b/data/teste.txt @@ -0,0 +1,10 @@ +teste0 +teste1 +teste2 +teste3 +teste4 +teste5 +teste6 +teste7 +teste8 +teste9 diff --git a/lib/bcr.h b/lib/bcr.h new file mode 100644 index 0000000000000000000000000000000000000000..2650a7baf9a584b958bf4e2b1b25f9a66754033c --- /dev/null +++ b/lib/bcr.h @@ -0,0 +1,30 @@ +#ifndef BCR_H +#define BCR_H + +class AnimationManage{ + + private: + int m_frameRate; + int m_numberOfBar; + std::string m_fileName; + + public: + AnimationManage(int frameRate=24, int numberOfBar=5); + + void setAnimationManage(int frameRate, int numberOfBar); + void setFrame(int frameRate); + void setNumberOfBar(int numberOfBar); + void setFileName(std::string fileName); + + int getFrame(){ return m_frameRate; } + int getnumberOfBar(){ return m_numberOfBar; } + std::string getFileName(){ return m_fileName; } + + //Nessa função eu preciso abrir o arquivo apartir da linha de commando, tratando os erros + //erros: arquivo nao encontrado, parametros invalidos + void initialize(int argc, char *argv[]); +}; + +void teste(); + +#endif diff --git a/main.cpp b/main.cpp index ad26e9fa40a843008d4d01399c0435afc952b100..7205c6e878a0e18e7efe4103e999baa299ea6bb9 100644 --- a/main.cpp +++ b/main.cpp @@ -1,7 +1,25 @@ #include <iostream> +#include <fstream> +#include <string> + +#include "lib/bcr.h" int main(int argc, char *argv[]){ + AnimationManage animation; + std::ifstream file(argv[1]); + std::string st; + + animation.initialize(argc, argv); + + if(file.is_open()){ + + while(!file.eof()){ + file >> st; + std::cout << st << std::endl; + } + } + // First Scope // Arquitetura gameloop // Gerenciador jogo diff --git a/src/bcr.cpp b/src/bcr.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2dbac54489b83e6baca16405aa4598bcc1d7ed83 --- /dev/null +++ b/src/bcr.cpp @@ -0,0 +1,96 @@ +#include <iostream> +#include <string> + +#include "../lib/bcr.h" + +void teste(){ std::cout << "TESTE" << std::endl; } + +//Construct +AnimationManage::AnimationManage(int frameRate, int numberOfBar){ + setAnimationManage(frameRate, numberOfBar); +} + +//start sets +void AnimationManage::setAnimationManage(int frameRate, int numberOfBar){ + m_frameRate = frameRate; + m_numberOfBar = numberOfBar; +} + +void AnimationManage::setFrame(int frameRate){ + m_frameRate = frameRate; +} + +void AnimationManage::setNumberOfBar(int numberOfBar){ + m_numberOfBar = numberOfBar; +} + +void AnimationManage::setFileName(std::string fileName){ + m_fileName = fileName; +} +//end sets + +void AnimationManage::initialize(int argc, char *argv[]){ + + std::string firstArgument; + std::string secondArgument; + + std::cout << "argc: " << argc << std::endl; + + if(argc == 1){// Caso o user nao passe argumentos retornar erro + + std::cout << "Sem parametros validos" << std::endl; + + }else if(argc == 2){//Caso o user passe apenas o nome do arquivo: carregar valores padroes + + setFileName(argv[1]); + std::cout << "file: " << getFileName() << std::endl; + + }else if(argc == 3){//parametros digitados mas invalidos + + std::cout << "Faltam parametros" << std::endl; + + } + else if(argc == 4){//Caso o user digite apenas um parametro + + firstArgument = argv[2]; + + if(firstArgument.compare("-b") == 0){//Check se o user quer mudar a qnt de barras + + std::cout << "Bars Command Valid" << std::endl; + //TODO Checkar se argumento 3(argv[3]) é um inteiro + + }else if(firstArgument.compare("-s") == 0){//Check se o user quer mudar a quantidade de frames + + std::cout << "Frames Command Valid" << std::endl; + //TODO Checkar se argumento 3(argv[3]) é um inteiro + + }else{//Se o user Digitar algum comando invalido + + std::cout << "Invalid Command" << std::endl; + } + }else if(argc == 5){//Segundo parametro invalido + + std::cout << "Segundo parametro invalido" << std::endl; + + }else if(argc == 6){//tamanho esperado + + firstArgument = argv[2]; + secondArgument = argv[4]; + //Check se Ambos argumentos sao validos + if(firstArgument.compare("-b") == 0 || firstArgument.compare("-s") == 0){ + if(secondArgument.compare(firstArgument) != 0){//Check se os args sao diferentes + if(secondArgument.compare("-b") == 0){ + std::cout << "primeiro arg: -s segundo arg: -b " << std::endl; + }else if(secondArgument.compare("-s") == 0){ + std::cout << "primeiro arg: -b segundo arg: -s " << std::endl; + }else{ + std::cout << "Comandos Invalidos" << std::endl; + } + }else{ + std::cout << "Mesmo comandos" << std::endl; + } + }else{//Check se os comandos sao invalidos(cmds inexistentes ou errados) + std::cout << "Comandos invalidos" << std::endl; + } + } +} diff --git a/ttt.txt b/ttt.txt new file mode 100644 index 0000000000000000000000000000000000000000..1dc98cbe49855a6ce7af87b0de984d3e185d843d --- /dev/null +++ b/ttt.txt @@ -0,0 +1,41 @@ +Duvidas: +Se o usuario digitar um comando valido e outro invalido "-b 10 -s a", eu devo considerar o comando valido ou discartar todos os comandos + + +eDtalhes barchart project + +./bcr ../data/arquivo.txt -s <fps> -b <qnt> +-s velocidade +-b quantidade de barras + +Tela Welcome + +Informações: Se conseguiu acessar o arquivo + +Welcome to the bar Chart Race, v1.0 +Copyright (C) 2020, Edson Cassiano + +>>> Preparing to read input file "../data/arquivo.txt"... + +>>> Processing data, please wait. +>>> Input file sucessfuly read. + +>>> We have "519" charts, each with 12 bars. + +Limite de barras - 12 barras +default 5 barras + +Classes + AnimationManeger - faz tudo - cria, ordena, captura printa e joga fora + banco de dados - + barchart - 1 unico grafico + +Lib de calcular os frames <thread> + +Para a leitura do arquivo siga os seguintes passos: +Eu tenho que ler cada subgrupo linha tamanho do sub grupo +Cada subgrupo tem o campo 0,1,2,3,4 +0(Contagem) +1(Titulo da barra) +2(---) +3(Categoria)