Commit 36109c15 authored by March's avatar March
Browse files

TP2 Base

parents
*.o
build
cmake-build-debug
.idea
CMakeLists.txt
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.5
# Default target executed when no arguments are given to make.
default_target: all
.PHONY : default_target
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
.NOTPARALLEL:
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =
.SUFFIXES: .hpux_make_needs_suffix_list
# Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake
# The command to remove a file.
RM = /usr/bin/cmake -E remove -f
# Escaping for special characters.
EQUALS = =
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /home/march/algoritmos2/2017/c2/tps/tp2/tp2_base
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /home/march/algoritmos2/2017/c2/tps/tp2/tp2_base
#=============================================================================
# Targets provided globally by CMake.
# Special rule for the target install
install: preinstall
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
/usr/bin/cmake -P cmake_install.cmake
.PHONY : install
# Special rule for the target install
install/fast: preinstall/fast
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
/usr/bin/cmake -P cmake_install.cmake
.PHONY : install/fast
# Special rule for the target list_install_components
list_install_components:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\""
.PHONY : list_install_components
# Special rule for the target list_install_components
list_install_components/fast: list_install_components
.PHONY : list_install_components/fast
# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
/usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache
# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast
# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..."
/usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available.
.PHONY : edit_cache
# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast
# Special rule for the target install/strip
install/strip: preinstall
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..."
/usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
.PHONY : install/strip
# Special rule for the target install/strip
install/strip/fast: install/strip
.PHONY : install/strip/fast
# Special rule for the target install/local
install/local: preinstall
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..."
/usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
.PHONY : install/local
# Special rule for the target install/local
install/local/fast: install/local
.PHONY : install/local/fast
# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /home/march/algoritmos2/2017/c2/tps/tp2/tp2_base/CMakeFiles /home/march/algoritmos2/2017/c2/tps/tp2/tp2_base/CMakeFiles/progress.marks
$(MAKE) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start /home/march/algoritmos2/2017/c2/tps/tp2/tp2_base/CMakeFiles 0
.PHONY : all
# The main clean target
clean:
$(MAKE) -f CMakeFiles/Makefile2 clean
.PHONY : clean
# The main clean target
clean/fast: clean
.PHONY : clean/fast
# Prepare targets for installation.
preinstall: all
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall
# Prepare targets for installation.
preinstall/fast:
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast
# clear depends
depend:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend
#=============================================================================
# Target rules for targets named correrTests
# Build rule for target.
correrTests: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 correrTests
.PHONY : correrTests
# fast build rule for target.
correrTests/fast:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/build
.PHONY : correrTests/fast
#=============================================================================
# Target rules for targets named doc_doxygen
# Build rule for target.
doc_doxygen: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 doc_doxygen
.PHONY : doc_doxygen
# fast build rule for target.
doc_doxygen/fast:
$(MAKE) -f CMakeFiles/doc_doxygen.dir/build.make CMakeFiles/doc_doxygen.dir/build
.PHONY : doc_doxygen/fast
#=============================================================================
# Target rules for targets named gtest
# Build rule for target.
gtest: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 gtest
.PHONY : gtest
# fast build rule for target.
gtest/fast:
$(MAKE) -f tests/google-test/CMakeFiles/gtest.dir/build.make tests/google-test/CMakeFiles/gtest.dir/build
.PHONY : gtest/fast
#=============================================================================
# Target rules for targets named gtest_main
# Build rule for target.
gtest_main: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 gtest_main
.PHONY : gtest_main
# fast build rule for target.
gtest_main/fast:
$(MAKE) -f tests/google-test/CMakeFiles/gtest_main.dir/build.make tests/google-test/CMakeFiles/gtest_main.dir/build
.PHONY : gtest_main/fast
src/BaseDeDatos.o: src/BaseDeDatos.cpp.o
.PHONY : src/BaseDeDatos.o
# target to build an object file
src/BaseDeDatos.cpp.o:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/BaseDeDatos.cpp.o
.PHONY : src/BaseDeDatos.cpp.o
src/BaseDeDatos.i: src/BaseDeDatos.cpp.i
.PHONY : src/BaseDeDatos.i
# target to preprocess a source file
src/BaseDeDatos.cpp.i:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/BaseDeDatos.cpp.i
.PHONY : src/BaseDeDatos.cpp.i
src/BaseDeDatos.s: src/BaseDeDatos.cpp.s
.PHONY : src/BaseDeDatos.s
# target to generate assembly for a file
src/BaseDeDatos.cpp.s:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/BaseDeDatos.cpp.s
.PHONY : src/BaseDeDatos.cpp.s
src/Dato.o: src/Dato.cpp.o
.PHONY : src/Dato.o
# target to build an object file
src/Dato.cpp.o:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/Dato.cpp.o
.PHONY : src/Dato.cpp.o
src/Dato.i: src/Dato.cpp.i
.PHONY : src/Dato.i
# target to preprocess a source file
src/Dato.cpp.i:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/Dato.cpp.i
.PHONY : src/Dato.cpp.i
src/Dato.s: src/Dato.cpp.s
.PHONY : src/Dato.s
# target to generate assembly for a file
src/Dato.cpp.s:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/Dato.cpp.s
.PHONY : src/Dato.cpp.s
src/Registro.o: src/Registro.cpp.o
.PHONY : src/Registro.o
# target to build an object file
src/Registro.cpp.o:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/Registro.cpp.o
.PHONY : src/Registro.cpp.o
src/Registro.i: src/Registro.cpp.i
.PHONY : src/Registro.i
# target to preprocess a source file
src/Registro.cpp.i:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/Registro.cpp.i
.PHONY : src/Registro.cpp.i
src/Registro.s: src/Registro.cpp.s
.PHONY : src/Registro.s
# target to generate assembly for a file
src/Registro.cpp.s:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/Registro.cpp.s
.PHONY : src/Registro.cpp.s
src/Restriccion.o: src/Restriccion.cpp.o
.PHONY : src/Restriccion.o
# target to build an object file
src/Restriccion.cpp.o:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/Restriccion.cpp.o
.PHONY : src/Restriccion.cpp.o
src/Restriccion.i: src/Restriccion.cpp.i
.PHONY : src/Restriccion.i
# target to preprocess a source file
src/Restriccion.cpp.i:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/Restriccion.cpp.i
.PHONY : src/Restriccion.cpp.i
src/Restriccion.s: src/Restriccion.cpp.s
.PHONY : src/Restriccion.s
# target to generate assembly for a file
src/Restriccion.cpp.s:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/Restriccion.cpp.s
.PHONY : src/Restriccion.cpp.s
src/Tabla.o: src/Tabla.cpp.o
.PHONY : src/Tabla.o
# target to build an object file
src/Tabla.cpp.o:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/Tabla.cpp.o
.PHONY : src/Tabla.cpp.o
src/Tabla.i: src/Tabla.cpp.i
.PHONY : src/Tabla.i
# target to preprocess a source file
src/Tabla.cpp.i:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/Tabla.cpp.i
.PHONY : src/Tabla.cpp.i
src/Tabla.s: src/Tabla.cpp.s
.PHONY : src/Tabla.s
# target to generate assembly for a file
src/Tabla.cpp.s:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/Tabla.cpp.s
.PHONY : src/Tabla.cpp.s
src/const_iterador_registros.o: src/const_iterador_registros.cpp.o
.PHONY : src/const_iterador_registros.o
# target to build an object file
src/const_iterador_registros.cpp.o:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/const_iterador_registros.cpp.o
.PHONY : src/const_iterador_registros.cpp.o
src/const_iterador_registros.i: src/const_iterador_registros.cpp.i
.PHONY : src/const_iterador_registros.i
# target to preprocess a source file
src/const_iterador_registros.cpp.i:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/const_iterador_registros.cpp.i
.PHONY : src/const_iterador_registros.cpp.i
src/const_iterador_registros.s: src/const_iterador_registros.cpp.s
.PHONY : src/const_iterador_registros.s
# target to generate assembly for a file
src/const_iterador_registros.cpp.s:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/src/const_iterador_registros.cpp.s
.PHONY : src/const_iterador_registros.cpp.s
tests/base_de_datos_test.o: tests/base_de_datos_test.cpp.o
.PHONY : tests/base_de_datos_test.o
# target to build an object file
tests/base_de_datos_test.cpp.o:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/base_de_datos_test.cpp.o
.PHONY : tests/base_de_datos_test.cpp.o
tests/base_de_datos_test.i: tests/base_de_datos_test.cpp.i
.PHONY : tests/base_de_datos_test.i
# target to preprocess a source file
tests/base_de_datos_test.cpp.i:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/base_de_datos_test.cpp.i
.PHONY : tests/base_de_datos_test.cpp.i
tests/base_de_datos_test.s: tests/base_de_datos_test.cpp.s
.PHONY : tests/base_de_datos_test.s
# target to generate assembly for a file
tests/base_de_datos_test.cpp.s:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/base_de_datos_test.cpp.s
.PHONY : tests/base_de_datos_test.cpp.s
tests/dato_test.o: tests/dato_test.cpp.o
.PHONY : tests/dato_test.o
# target to build an object file
tests/dato_test.cpp.o:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/dato_test.cpp.o
.PHONY : tests/dato_test.cpp.o
tests/dato_test.i: tests/dato_test.cpp.i
.PHONY : tests/dato_test.i
# target to preprocess a source file
tests/dato_test.cpp.i:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/dato_test.cpp.i
.PHONY : tests/dato_test.cpp.i
tests/dato_test.s: tests/dato_test.cpp.s
.PHONY : tests/dato_test.s
# target to generate assembly for a file
tests/dato_test.cpp.s:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/dato_test.cpp.s
.PHONY : tests/dato_test.cpp.s
tests/linear_map_tests.o: tests/linear_map_tests.cpp.o
.PHONY : tests/linear_map_tests.o
# target to build an object file
tests/linear_map_tests.cpp.o:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/linear_map_tests.cpp.o
.PHONY : tests/linear_map_tests.cpp.o
tests/linear_map_tests.i: tests/linear_map_tests.cpp.i
.PHONY : tests/linear_map_tests.i
# target to preprocess a source file
tests/linear_map_tests.cpp.i:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/linear_map_tests.cpp.i
.PHONY : tests/linear_map_tests.cpp.i
tests/linear_map_tests.s: tests/linear_map_tests.cpp.s
.PHONY : tests/linear_map_tests.s
# target to generate assembly for a file
tests/linear_map_tests.cpp.s:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/linear_map_tests.cpp.s
.PHONY : tests/linear_map_tests.cpp.s
tests/linear_set_tests.o: tests/linear_set_tests.cpp.o
.PHONY : tests/linear_set_tests.o
# target to build an object file
tests/linear_set_tests.cpp.o:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/linear_set_tests.cpp.o
.PHONY : tests/linear_set_tests.cpp.o
tests/linear_set_tests.i: tests/linear_set_tests.cpp.i
.PHONY : tests/linear_set_tests.i
# target to preprocess a source file
tests/linear_set_tests.cpp.i:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/linear_set_tests.cpp.i
.PHONY : tests/linear_set_tests.cpp.i
tests/linear_set_tests.s: tests/linear_set_tests.cpp.s
.PHONY : tests/linear_set_tests.s
# target to generate assembly for a file
tests/linear_set_tests.cpp.s:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/linear_set_tests.cpp.s
.PHONY : tests/linear_set_tests.cpp.s
tests/registro_test.o: tests/registro_test.cpp.o
.PHONY : tests/registro_test.o
# target to build an object file
tests/registro_test.cpp.o:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/registro_test.cpp.o
.PHONY : tests/registro_test.cpp.o
tests/registro_test.i: tests/registro_test.cpp.i
.PHONY : tests/registro_test.i
# target to preprocess a source file
tests/registro_test.cpp.i:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/registro_test.cpp.i
.PHONY : tests/registro_test.cpp.i
tests/registro_test.s: tests/registro_test.cpp.s
.PHONY : tests/registro_test.s
# target to generate assembly for a file
tests/registro_test.cpp.s:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/registro_test.cpp.s
.PHONY : tests/registro_test.cpp.s
tests/string_map_test.o: tests/string_map_test.cpp.o
.PHONY : tests/string_map_test.o
# target to build an object file
tests/string_map_test.cpp.o:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/string_map_test.cpp.o
.PHONY : tests/string_map_test.cpp.o
tests/string_map_test.i: tests/string_map_test.cpp.i
.PHONY : tests/string_map_test.i
# target to preprocess a source file
tests/string_map_test.cpp.i:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/string_map_test.cpp.i
.PHONY : tests/string_map_test.cpp.i
tests/string_map_test.s: tests/string_map_test.cpp.s
.PHONY : tests/string_map_test.s
# target to generate assembly for a file
tests/string_map_test.cpp.s:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/string_map_test.cpp.s
.PHONY : tests/string_map_test.cpp.s
tests/tabla_test.o: tests/tabla_test.cpp.o
.PHONY : tests/tabla_test.o
# target to build an object file
tests/tabla_test.cpp.o:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/tabla_test.cpp.o
.PHONY : tests/tabla_test.cpp.o
tests/tabla_test.i: tests/tabla_test.cpp.i
.PHONY : tests/tabla_test.i
# target to preprocess a source file
tests/tabla_test.cpp.i:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/tabla_test.cpp.i
.PHONY : tests/tabla_test.cpp.i
tests/tabla_test.s: tests/tabla_test.cpp.s
.PHONY : tests/tabla_test.s
# target to generate assembly for a file
tests/tabla_test.cpp.s:
$(MAKE) -f CMakeFiles/correrTests.dir/build.make CMakeFiles/correrTests.dir/tests/tabla_test.cpp.s
.PHONY : tests/tabla_test.cpp.s
# Help Target
help:
@echo "The following are some of the valid targets for this Makefile:"
@echo "... all (the default if no target is provided)"
@echo "... clean"
@echo "... depend"
@echo "... install"
@echo "... list_install_components"
@echo "... rebuild_cache"
@echo "... edit_cache"
@echo "... correrTests"
@echo "... doc_doxygen"
@echo "... install/strip"
@echo "... install/local"
@echo "... gtest"
@echo "... gtest_main"
@echo "... src/BaseDeDatos.o"
@echo "... src/BaseDeDatos.i"
@echo "... src/BaseDeDatos.s"
@echo "... src/Dato.o"
@echo "... src/Dato.i"
@echo "... src/Dato.s"
@echo "... src/Registro.o"
@echo "... src/Registro.i"
@echo "... src/Registro.s"
@echo "... src/Restriccion.o"
@echo "... src/Restriccion.i"
@echo "... src/Restriccion.s"
@echo "... src/Tabla.o"
@echo "... src/Tabla.i"
@echo "... src/Tabla.s"
@echo "... src/const_iterador_registros.o"
@echo "... src/const_iterador_registros.i"
@echo "... src/const_iterador_registros.s"
@echo "... tests/base_de_datos_test.o"
@echo "... tests/base_de_datos_test.i"
@echo "... tests/base_de_datos_test.s"
@echo "... tests/dato_test.o"
@echo "... tests/dato_test.i"
@echo "... tests/dato_test.s"
@echo "... tests/linear_map_tests.o"
@echo "... tests/linear_map_tests.i"
@echo "... tests/linear_map_tests.s"
@echo "... tests/linear_set_tests.o"
@echo "... tests/linear_set_tests.i"
@echo "... tests/linear_set_tests.s"
@echo "... tests/registro_test.o"
@echo "... tests/registro_test.i"
@echo "... tests/registro_test.s"
@echo "... tests/string_map_test.o"
@echo "... tests/string_map_test.i"
@echo "... tests/string_map_test.s"
@echo "... tests/tabla_test.o"
@echo "... tests/tabla_test.i"
@echo "... tests/tabla_test.s"
.PHONY : help
#=============================================================================
# Special targets to cleanup operation of make.
# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system
# Para empezar
Es necesario bajar el código del este repositorio. Esto puede hacerse
utilizando directamente `git` o alternativamente bajando el proyecto como un
`zip`. Se recomienda la primera opción que se explica a continuación.
1. `git clone https://git.exactas.uba.ar/mmiguel/aed2-2c2017-tp2.git`
2. (Opcional) Desde CLion, ir a File -> Import Project, "Open Project".
Una vez que termina la carga del proyecto, para correr los tests,
elegir "correrTests" desde la esquina superior derecha y
hacer click en el botón Play.
# Cómo correr los tests desde la línea de comandos (si no usan CLion)
1. mkdir build && cd build
2. cmake ..
3. make
4. ./correrTests
Para volver a compilar, simplemente correr "make" de nuevo.
En caso de que no funcione correctamente la compilación, pueden borrar
el directorio "build" y volver a realizar los 4 pasos.
# Install script for directory: /home/march/algoritmos2/2017/c2/tps/tp2/tp2_base
# Set the install prefix
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr/local")
endif()
string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
# Set the install configuration name.
if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
if(BUILD_TYPE)
string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
else()
set(CMAKE_INSTALL_CONFIG_NAME "")
endif()
message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
endif()
# Set the component getting installed.
if(NOT CMAKE_INSTALL_COMPONENT)
if(COMPONENT)
message(STATUS "Install component: \"${COMPONENT}\"")
set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
else()
set(CMAKE_INSTALL_COMPONENT)
endif()
endif()
# Install shared libraries without execute permission?
if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
set(CMAKE_INSTALL_SO_NO_EXE "1")
endif()
if(NOT CMAKE_INSTALL_LOCAL_ONLY)
# Include the install script for each subdirectory.
include("/home/march/algoritmos2/2017/c2/tps/tp2/tp2_base/tests/google-test/cmake_install.cmake")
endif()
if(CMAKE_INSTALL_COMPONENT)
set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt")
else()
set(CMAKE_INSTALL_MANIFEST "install_manifest.txt")
endif()
string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT
"${CMAKE_INSTALL_MANIFEST_FILES}")
file(WRITE "/home/march/algoritmos2/2017/c2/tps/tp2/tp2_base/${CMAKE_INSTALL_MANIFEST}"
"${CMAKE_INSTALL_MANIFEST_CONTENT}")
This diff is collapsed.
\mainpage
¡Bienvenido a la documentación del TP2 de AED2 del 2do Cuatrimestre 2017!
* Para ver la documentación de las clases, ir a **Clases**
* Para ver el enunciado, buscar el pdf en `docs/enunciado`
#include "BaseDeDatos.h"
#include <list>
#include <tuple>
#include <algorithm>
BaseDeDatos::BaseDeDatos(){};
void BaseDeDatos::crearTabla(const string &nombre,
const linear_set<string> &claves,
const vector<string> &campos,
const vector<Dato> &tipos) {
_nombres_tablas.insert(nombre);
_tablas.insert(make_pair(nombre, Tabla(claves, campos, tipos)));
}
void BaseDeDatos::agregarRegistro(const Registro &r, const string &nombre) {
Tabla &t = _tablas.at(nombre);
t.agregarRegistro(r);
}
const linear_set<string> &BaseDeDatos::tablas() const { return _nombres_tablas; }
const Tabla &BaseDeDatos::dameTabla(const string &nombre) const {
return _tablas.at(nombre);
}
int BaseDeDatos::uso_criterio(const BaseDeDatos::Criterio &criterio) const {
if (_uso_criterios.count(criterio)) {
return _uso_criterios.at(criterio);
} else {
return 0;
}
}
bool BaseDeDatos::registroValido(const Registro &r,
const string &nombre) const {
const Tabla &t = _tablas.at(nombre);
return (t.campos() == r.campos() and _mismos_tipos(r, t) and
_no_repite(r, t));
}
bool BaseDeDatos::_mismos_tipos(const Registro &r, const Tabla &t) const {
for (auto c : t.campos()) {
if (r.dato(c).esNat() != t.tipoCampo(c).esNat()) {
return false;
}
}
return true;
}
bool BaseDeDatos::_no_repite(const Registro &r, const Tabla &t) const {
list<Registro> filtrados(t.registros().begin(), t.registros().end());
for (auto clave : t.claves()) {
_filtrar_registros(clave, r.dato(clave), filtrados);
}
return filtrados.empty();
}
list<Registro> &
BaseDeDatos::_filtrar_registros(const string &campo, const Dato &valor,
list<Registro> &registros) const {
return _filtrar_registros(campo, valor, registros, true);
}
list<Registro> &BaseDeDatos::_filtrar_registros(const string &campo,
const Dato &valor,
list<Registro> &registros,
bool igualdad) const {
auto iter = registros.begin();
while ( iter != registros.end()) {
auto now = iter;
iter++;
if ((not igualdad) xor now->dato(campo) != valor) {
registros.erase(now);
}
}
return registros;
}
pair<vector<string>, vector<Dato> > BaseDeDatos::_tipos_tabla(const Tabla &t) {
vector<string> res_campos;
vector<Dato> res_tipos;
for (auto c : t.campos()) {
res_campos.push_back(c);
res_tipos.push_back(t.tipoCampo(c));
}
return make_pair(res_campos, res_tipos);
}
bool BaseDeDatos::criterioValido(const Criterio &c,
const string &nombre) const {
const Tabla &t = _tablas.at(nombre);
for (auto restriccion : c) {
if (not t.campos().count(restriccion.campo())) {
return false;
}
if (t.tipoCampo(restriccion.campo()).esNat() !=
restriccion.dato().esNat()) {
return false;
}
}
return true;
}
Tabla BaseDeDatos::busqueda(const BaseDeDatos::Criterio &c,
const string &nombre) {
if (_uso_criterios.count(c)) {
_uso_criterios.at(c)++;
} else {
_uso_criterios.insert(make_pair(c, 1));
}
const Tabla &ref = dameTabla(nombre);
auto campos_datos = _tipos_tabla(ref);
Tabla res(ref.claves(), campos_datos.first, campos_datos.second);
list<Registro> regs(ref.registros().begin(), ref.registros().end());
for (auto restriccion : c) {
_filtrar_registros(restriccion.campo(), restriccion.dato(),
regs, restriccion.igual());
}
for (auto r : regs) {
res.agregarRegistro(r);
}
return res;
}
linear_set<BaseDeDatos::Criterio> BaseDeDatos::top_criterios() const {
linear_set<Criterio> ret;
int max = 0;
for (auto crit_count : _uso_criterios) {
if (crit_count.second >= max) {
if (crit_count.second > max) {
ret = linear_set<Criterio>();
max = crit_count.second;
}
ret.insert(crit_count.first);
}
}
return ret;
}
#ifndef _BASEDEDATOS_H
#define _BASEDEDATOS_H
#include "Registro.h"
#include "Restriccion.h"
#include "Tabla.h"
#include <utility>
#include <list>
#include <string>
#include "linear_map.h"
#include "linear_set.h"
#include "utils.h"
using namespace std;
/**
* @brief Una base de datos es un administrador de tablas con funciones de
* búsqueda.
*
* Una base de datos permite administrar tablas identificadas por registro.
* Permite saber si se puede agegar un registro a una tabla y luego agregarlo.
* Permite realizar filtros del contenido de tablas mediante criterios de
* búsqueda. Además mantiene estadísticas del uso de los criterios.
*/
class BaseDeDatos {
public:
/** @brief Criterio de búsqueda para una base de datos */
typedef linear_set<Restriccion> Criterio;
/**
* @brief Inicializa una base de datos sin tablas.
*
* \pre true
* \post \P{this} = nuevaDB
*
* \complexity{\O(1)}
*/
BaseDeDatos();
/**
* @brief Crea una nueva tabla en la base de datos.
*
* @param nombre Nombre identificador de la tabla
* @param claves Claves de la tabla a crear
* @param campos Campos de la tabla a crear
* @param tipos Tipos para los campos de la tabla a crear
*
* \pre db = \P{this} \LAND
* \LNOT (nombre \IN tablas(\P{this})) \LAND
* \LAND \LNOT \EMPTYSET?(claves) \LAND
* \FORALL (c: campo) c \IN claves \IMPLICA c \IN campos \LAND
* long(campos) = long(tipos) \LAND sinRepetidos(campos)
* \post \P{this} = agregarTabla(nuevaTabla(claves, nuevoRegistro(campos, tipos)), db)
*
* \complexity{\O(C)}
*/
void crearTabla(const string &nombre, const linear_set<string> &claves,
const vector<string> &campos, const vector<Dato> &tipos);
/**
* @brief Agrega un registro a la tabla parámetro
*
* @param r Registro a agregar
* @param nombre Nombre de la tabla donde se agrega el registro
*
* \pre db = \P{this} \LAND nombre \IN tablas(\P{this}) \LAND
* puedoInsertar?(r, dameTabla(\P{this}))
* \post \P{this} = insertarEntrada(r, nombre, db)
*
* \complexity{\O(T + copy(reg))}
*/
void agregarRegistro(const Registro &r, const string &nombre);
/**
* @brief Devuelve el conjunto de tablas existentes en la base.
*
* El conjunto de nombres se devuelve por referencia no-modificable.
*
* \pre true
* \post \P{res} = tablas(\P{this})
*
* \complexity{\O(1)}
*/
const linear_set<string> &tablas() const;
/**
* @brief Devuelve la tabla asociada al nombre.
*
* La tabla se devuelve por referencia no modificable.
*
* @param nombre Nombre de la tabla buscada.
*
* \pre nombre \IN tablas(\P{this})
* \post \P{res} = dameTabla(nombre, \P{this})
*
* \complexity{O(T)}
*/
const Tabla &dameTabla(const string &nombre) const;
/**
* @brief Devuelve la cantidad de usos que tiene un criterio
*
* @param criterio Criterio por el cual se consulta.
*
* \pre nombre \IN tablas(\P{this})
* \post \P{res} = usoCriterio(criterio, \P{this})
*
* \complexity{\O(#cs * cmp(Criterio))}
*/
int uso_criterio(const Criterio &criterio) const;
/**
* @brief Evalúa si un registro puede ingresarse en la tabla parámetro.
*
* @param r Registro a ingresar en la tabla.
* @param nombre Nombre de la tabla.
*
* \pre nombre \IN tablas(\P{this})
* \post \P{res} = puedoInsertar?(r, dameTabla(nombre, \P{this}))
*
* \complexity{\O(T + C^2 + (c * C + c * n * (C + L)))}
*/
bool registroValido(const Registro &r, const string &nombre) const;
/**
* @brief Evalúa si un criterio puede aplicarse en la tabla parámetro.
*
* @param c Criterio a utilizar.
* @param nombre Nombre de la tabla.
*
* \pre tabla \IN tablas(\P{this})
* \post \P{res} = criterioValido(c, nombre, \P{this})
*
* \complexity{\O(T + cr * C)}
*/
bool criterioValido(const Criterio &c, const string &nombre) const;
/**
* @brief Devuelve el resultado de buscar en una tabla con un criterio.
*
* @param c Criterio de búsqueda utilizado.
* @param nombre Nombre de la tabla.
*
* \pre nombre \IN tablas(\P{this}) \LAND criterioValido(c, nombre, \P{this})
* \post \P{res} = buscar(c, nombre, \P{this})
*
* \complexity{\O(T + cs * cmp(Criterio) + cr * n * (C + L + copy(reg)))}
*/
Tabla busqueda(const Criterio &c, const string &nombre);
/**
* @brief Devuelve los criterios de máximo uso.
*
* \pre true
* \post \FORALL (c : Criterio) [c \IN \P{res} \IFF
* \FORALL (c' : Criterio) usoCriterio(c, db) >= usoCriterio(c', db)]
*
* \complexity{\O(cs * copy(Criterio))}
*/
linear_set<Criterio> top_criterios() const;
private:
///////////////////////////////////////////////////////////////////////////////////////////////////
/** \name Representación
* rep: basededatos \TO bool\n
* rep(bd) \EQUIV
* * _nombres_tablas = claves(_tablas) \LAND
* * \FORALL (c : Criterio) c \IN claves(_uso_criterios) \IMPLIES
* * (
* * \EXISTS (n : string) n \IN _nombres_tablas
* * \LAND criterioValido(c, n, db)
* * ) \LAND
* * obtener(c, _uso_criterios) > 0
*
* abs: registro \TO Registro\n
* abs(r) \EQUIV r' \|
* * campos(r') = _campos \LAND
* * \FORALL (c : string) c \in _campos \IMPLIES valor(c, r') = valor(c,
* _datos)
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////
/** @{ */
linear_set<string> _nombres_tablas;
linear_map<string, Tabla> _tablas;
linear_map<Criterio, int> _uso_criterios;
/** @} */
/** @{ */
/**
* @brief Revisa si los campos del registro y la tabla tienen el mismo tipo.
*
* \pre campos(r) == campos(t)
* \post \P{res} == \FORALL (c : campo) c \IN campos(r) \IMPLIES
* Nat?(valor(c, r)) == tipoCampo(c, t)
*
* \complexity{O(C^2)}
*/
bool _mismos_tipos(const Registro &r, const Tabla &t) const;
/**
* @brief Revisa si el registro no repite claves en la tabla.
*
* \pre compatible(r, t)
* \post \P{res} = \FORALL (r' : Registro) r \IN registros(t) \IMPLIES
* \EXISTS (c : campo) c \IN claves(t) \LAND valor(c, r') != valor(c, r)
*
* \complexity{O(c * C + c * n * (C + L))}
*/
bool _no_repite(const Registro &r, const Tabla &t) const;
/**
* @brief Filtra la lista de registros parametro según el criterio.
*
* El resultado tiene aliasing con el parámetro registros.
*
* \pre \FORALL (r : Registro) r \IN registros \IMPLIES campo \IN
* campos(r) \LAND tipo?(valor(campo, r)) = tipo?(valor)
* \post \P{res} = filtrarRegistrosSegunRestriccion(
* nueva(campo, valor, igualdad), registros)
*/
list<Registro> &_filtrar_registros(const string &campo, const Dato &valor,
list<Registro> &registros,
bool igualdad) const;
/**
* @brief Filtra la lista de registros parametro según el criterio.
*
* El resultado tiene aliasing con el parámetro registros.
*
* \pre \FORALL (r : Registro) r \IN registros \IMPLIES campo \IN
* campos(r) \LAND tipo?(valor(campo, r)) = tipo?(valor)
* \post \P{res} = filtrarRegistrosSegunRestriccion(
* nueva(campo, valor, true), registros)
*/
list<Registro> &_filtrar_registros(const string &campo, const Dato &valor,
list<Registro> &registros) const;
/**
* @brief Obtiene los campos y tipos de una tabla.
*
* \pre true
* \post (\FORALL (c : Campo) está?(c, \P1(\P{res})) \IFF c \IN campos(t))
* \LAND #(campos(t)) = long(\P1(\P{res}))
* \LAND \FORALL (i : Nat) 0 \LEQ i < #(campos(t)) \IMPLIES
* tipo?(\P2(\P{res})[i]) = tipoCampo(\P1(\P{res})[i], t)
*/
pair<vector<string>, vector<Dato> > _tipos_tabla(const Tabla &t);
/** @} */
};
#endif
#include "Dato.h"
#include <iostream>
#include <tuple>
using namespace std;
Dato::Dato(int valorNat) :
_valorNat(valorNat), _valorStr(""), _esNat(true) {};
Dato::Dato(const string & valorStr) :
_valorNat(0), _valorStr(valorStr), _esNat(false) {};
bool Dato::esNat() const {
return _esNat;
};
bool Dato::esString() const {
return not esNat();
}
string Dato::valorStr() const {
return _valorStr;
};
int Dato::valorNat() const {
return _valorNat;
};
Dato datoNat(int valorNat) {
return Dato(valorNat);
}
Dato datoStr(string valorStr) {
return Dato(valorStr);
}
Dato tipoNat = datoNat(0);
Dato tipoStr = datoStr("");
bool operator==(const Dato& d1, const Dato& d2) {
if (d1.esNat() == d2.esNat()) {
if (d1.esNat()) {
return d1.valorNat() == d2.valorNat();
} else {
return d1.valorStr() == d2.valorStr();
}
}
return false;
}
bool operator!=(const Dato& d1, const Dato& d2) {
return !(d1 == d2);
}
bool operator<(const Dato& d1, const Dato& d2) {
return (make_tuple(d1.esNat(), d1._valorNat, d1._valorStr) <
make_tuple(d2.esNat(), d2._valorNat, d2._valorStr));
}
ostream & operator<<(ostream &os, const Dato& d) {
if (d.esNat()) {
os << to_string(d.valorNat());
} else {
os << d.valorStr();
}
return os;
}
#ifndef DATO_H
#define DATO_H
#include <string>
using namespace std;
/**
* @brief Representa un Dato de una Base de Datos.
*
* **se explica con** TAD Dato
*/
class Dato {
public:
/**
* @brief Constructor de dato con valor nat
*
* @param valorNat valor natural del dato
*
* \pre true
* \post \P{res} \IGOBS datoNat(valorNat)
* \complexity{\O(1)}
*/
Dato(int valorNat);
/**
* @brief Constructor de dato con valor string
*
* @param valorStr valor string del dato
*
* \pre true
* \post \P{res} \IGOBS datoStr(valorStr)
* \complexity{\O(1)}
*/
Dato(const string& valorStr);
/**
* @brief True si el dato es de tipo nat
*
* \pre true
* \post \P{res} \IGOBS Nat?(\P{this})
* \complexity{\O(1)}
*/
bool esNat() const;
/**
* @brief True si el dato es de tipo string
*
* \pre true
* \post \P{res} \IGOBS String?(\P{this})
* \complexity{\O(1)}
*/
bool esString() const;
/**
* @brief El valor del dato
*
* Devuelve el valor por copia.
*
* \pre String?(\P{this})
* \post \P{res} \IGOBS valorStr(\P{this})
* \complexity{\O(1)}
*/
string valorStr() const;
/**
* @brief El valor del dato
*
* Devuelve el valor por copia.
*
* \pre Nat?(\P{this})
* \post \P{res} \IGOBS valorNat(\P{this})
* \complexity{\O(1)}
*/
int valorNat() const;
private:
///////////////////////////////////////////////////////////////////////////////////////////////////
/** \name Representación
* rep: dato \TO bool\n
* rep(d) \EQUIV
* * _esNat \IMPLIES _valorStr = "" \LOR \LNOT _esNat \IMPLIES _valorNat = 0
*
* abs: dato \TO Dato\n
* abs(d) \EQUIV d' \|
* * Nat?(d') = d._esNat \LAND
* * Nat?(d') \IMPLIES valorNat(d) = d._valorNat \LAND
* * \NEG Nat?(d') \IMPLIES valorStr(d) = d._valorStr
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////
/** @{ */
/** @brief Valor cuando el dato es nat. */
int _valorNat;
/** @brief Valor cuando el dato es nat. */
string _valorStr;
/** @brief Define si el dato es nat. */
bool _esNat;
/** @} */
/** @brief Comparador de datos */
friend bool operator<(const Dato&, const Dato&);
};
Dato datoNat(int valorNat);
Dato datoStr(string valorStr);
extern Dato tipoNat;
extern Dato tipoStr;
bool operator==(const Dato&, const Dato&);
bool operator!=(const Dato&, const Dato&);
ostream &operator<<(ostream &, const Dato&);
#endif // DATO_H
#include <iostream>
#include "Registro.h"
#include "utils.h"
using namespace std;
Registro::Registro(const vector<string>& campos, const vector<Dato>& datos) :
_campos(campos.begin(), campos.end()) {
for (int i = 0; i < campos.size(); i++) {
_datos.fast_insert(make_pair(campos[i], datos[i]));
}
};
const Dato& Registro::dato(const string& campo) const {
return _datos.at(campo);
}
const linear_set<string>& Registro::campos() const {
return _campos;
}
bool operator==(const Registro& r1, const Registro& r2) {
linear_set<string> c1 = r1.campos();
linear_set<string> c2 = r2.campos();
if (not (c1 == c2)) {
return false;
}
linear_set<string> campos = r1.campos();
for (auto c : campos) {
if (r1.dato(c) != r2.dato(c)) {
return false;
}
}
return true;
}
ostream &operator<<(ostream &os, const Registro &r) {
os << r._datos;
return os;
}
#ifndef _REGISTRO_H
#define _REGISTRO_H
#include <vector>
#include <iostream>
#include "Dato.h"
#include "linear_set.h"
#include "linear_map.h"
using namespace std;
/**
* @brief Representa un registro de una tabla.
*
* Un registro asocia campos identificados con un string con valores
* específicos.
*
* **se explica con** TAD Diccionario(string, Dato)
*/
class Registro {
public:
/**
* @brief Genera un nuevo registro con los campos y valores designados.
*
* \pre long(campos) = long(datos)
* \post \P{res} = nuevoRegistro(campos, datos)
*
* \complexity{\O(long(campos) * copy(campo) * copy(dato))}
*/
Registro(const vector<string>& campos, const vector<Dato>& datos);
/**
* @brief Devuelve el dato asociado a un campo.
*
* Devuelve el dato por referencia no modificable.
*
* \pre campo \in campos(\P{this})
* \post \P{res} = valor(campo, \P{this})
*
* \complexity{\O(long(campos(\P{this})) * cmp(campo))}
*/
const Dato& dato(const string& campo) const;
/**
* @brief Devuelve los campos definidos en un registro
*
* El conjunto de campos se devuelve por referencia
*
* \pre true
* \post \P{res} = campos(\P{this})
*
* \complexity{\O(1)}
*/
const linear_set<string>& campos() const;
private:
///////////////////////////////////////////////////////////////////////////////////////////////////
/** \name Representación
* rep: registro \TO bool\n
* rep(d) \EQUIV
* * _campos = claves(_datos)
*
* abs: registro \TO Registro\n
* abs(r) \EQUIV r' \|
* * campos(r') = _campos \LAND
* * \FORALL (c : string) c \in _campos \IMPLIES valor(c, r') = valor(c,
* _datos)
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////
/** @{ */
linear_set<string> _campos;
linear_map<string, Dato> _datos;
/** @} */
friend ostream &operator<<(ostream &, const Registro &);
};
bool operator==(const Registro&, const Registro&);
ostream &operator<<(ostream &, const Registro &);
#endif //_REGISTRO_H
#include "Restriccion.h"
#include <tuple>
Restriccion::Restriccion(const string &campo, const Dato &dato, bool igual)
: _campo(campo), _dato(dato), _igual(igual){};
const string &Restriccion::campo() const { return _campo; }
const Dato &Restriccion::dato() const { return _dato; }
const bool &Restriccion::igual() const { return _igual; }
bool operator==(const Restriccion &r1, const Restriccion &r2) {
return (r1.campo() == r2.campo() and r1.dato() == r2.dato() and
r1.igual() == r2.igual());
}
bool operator<(const Restriccion &r1, const Restriccion &r2) {
return (make_tuple(r1.campo(), r1.dato(), r1.igual()) <
make_tuple(r2.campo(), r2.dato(), r2.igual()));
}
Restriccion Rig(const string &campo, const string &valor) {
return Restriccion(campo, datoStr(valor), true);
}
Restriccion Rig(const string &campo, const int &valor) {
return Restriccion(campo, datoNat(valor), true);
}
Restriccion Rdif(const string &campo, const string &valor) {
return Restriccion(campo, datoStr(valor), false);
}
Restriccion Rdif(const string &campo, const int &valor) {
return Restriccion(campo, datoNat(valor), false);
}
#ifndef RESTRICCION_H
#define RESTRICCION_H
#include <string>
#include "Dato.h"
class Restriccion {
public:
Restriccion(const string& campo, const Dato& dato, bool igual);
const string& campo() const;
const Dato& dato() const;
const bool& igual() const;
private:
string _campo;
Dato _dato;
bool _igual;
};
bool operator==(const Restriccion& r1, const Restriccion& r2);
bool operator<(const Restriccion& r1, const Restriccion& r2);
Restriccion Rig(const string& campo, const string& valor);
Restriccion Rig(const string& campo, const int& valor);
Restriccion Rdif(const string& campo, const string& valor);
Restriccion Rdif(const string& campo, const int& valor);
#endif
#include "Tabla.h"
#include "utils.h"
using namespace std;
Tabla::Tabla(const linear_set<string> &claves,
const vector<string> &campos,
const vector<Dato> &tipos)
: _claves(claves) {
for (int i = 0; i < campos.size(); i++) {
_tipos.fast_insert(make_pair(campos[i], tipos[i]));
_campos.insert(campos[i]);
}
}
void Tabla::agregarRegistro(const Registro& r) {
_registros.insert(r);
}
const linear_set<string>& Tabla::campos() const {
return _campos;
}
const linear_set<string>& Tabla::claves() const {
return _claves;
}
const Dato& Tabla::tipoCampo(const string& campo) const {
return _tipos.at(campo);
}
const linear_set<Registro> &Tabla::registros() const {
return _registros;
}
Tabla::const_iterador_registros Tabla::registros_begin() const {
return Tabla::const_iterador_registros(_registros.begin());
}
Tabla::const_iterador_registros Tabla::registros_end() const {
return Tabla::const_iterador_registros(_registros.end());
}
int Tabla::cant_registros() const {
return _registros.size();
}
bool operator==(const Tabla& t1, const Tabla& t2) {
if (not (t1.campos() == t2.campos())) {
return false;
} else if (not (t1.claves() == t2.claves())) {
return false;
} else {
linear_set<string> cs = t1.campos();
for (auto c : cs) {
if (t1.tipoCampo(c).esNat() != t2.tipoCampo(c).esNat()) {
return false;
}
}
return t1.registros() == t2.registros();
}
}
bool operator!=(const Tabla& t1, const Tabla& t2) {
return not (t1 == t2);
}
#ifndef TABLA_H
#define TABLA_H
#include <string>
#include "linear_map.h"
#include "linear_set.h"
#include "Dato.h"
#include "Registro.h"
using namespace std;
/**
* @brief Representa una tabla de una base de datos.
*
* Una tabla es una colección de registros que cumplen la descripción de la
* misma. La descripción de una tabla consiste en una serie de nombres que
* describen los campos y un tipo para cada campo que explicita el tipo de dato
* que un registro puede tener en ese campo.
*
* La descripción también selecciona un subconjunto de los campos como \i
* claves. Dada las claves, una tabla no puede tener dos registros con los
* mismos valores para todos los campos claves.
*/
class Tabla {
public:
// Forward declaration
class const_iterador_registros;
/**
* @brief Inicializa una tabla sin registros y con la descripción parámetro.
*
* @param claves Subconjunto de los campos que son claves.
* @param campos Conjunto de nombres de claves. El órden se corresponde con
* el de datos
* @param tipos Conjunto de datos cuyo tipo define el tipo admisible en cada
* campo. El valor de los datos se ignora.
*
* \pre \LNOT \EMPTYSET ?(c) \LAND
* \FORALL (c: campo) c \in claves \IMPLIES esta?(c, campos) \LAND
* long(campos) = long(tipos) \LAND sinRepetidos(campos)
* \post \P{res} = nuevaTabla(claves, nuevoRegistro(campos, tipos))
*
* \complexity{\O(long(campos) * (copy(campo) + copy(dato)))}
*/
Tabla(const linear_set<string> &claves, const vector<string> &campos,
const vector<Dato> &tipos);
/**
* @brief Inserta un nuevo registro en la tabla.
*
* @param r Registro a agregar
*
* \pre t = \P{this} \LAND campos(r) = campos(t) \LAND puedoInsertar?(r, t)
* \post \P{this} = agregarRegistro(r, t)
*
* \complexity{\O(copy(registro))}
*/
void agregarRegistro(const Registro &r);
/**
* @brief Campos de la tabla
*
* El conjunto se devuelve por referencia no-modificable
*
* \pre true
* \post \P{res} = campos(\P{this})
*
* \complexity{\O(1)}
*/
const linear_set<string> &campos() const;
/**
* @brief Tipo del campo parámetro para la tabla
*
* El dato se devuelve por referencia no-modificable.
* El dato se utiliza solo para representar el tipo. Su valor se ignora.
*
* \pre campo \IN campos(\P{this})
* \post tipoCampo(campo, \P{this})
*
* \complexity{\O(#(campos(\P{this})) * cmp(campo)}
*/
const Dato &tipoCampo(const string &campo) const;
/**
* @brief Subconjunto de campos que son clave
*
* El conjunto se devuelve por referencia no-modificable.
*
* \pre true
* \post \P{res} = claves(\P{this})
*
* \complexity{\O(1)}
*/
const linear_set<string> &claves() const;
const linear_set<Registro>& registros() const;
int cant_registros() const;
/**
* @brief Iterador al inicio de los registros de la tabla.
*
* El iterador resultado es conformante con [std::InputIterator](http://en.cppreference.com/w/cpp/concept/InputIterator)
*
* \pre true
* \post El iterador \P{res} recorre los registros de la tabla en un orden
* no definido.
*
* \complexity{\O(1)}
*/
const_iterador_registros registros_begin() const;
/**
* @brief Iterador al final de los registros de la tabla.
*
* El iterador resultado es conformante con [std::InputIterator](http://en.cppreference.com/w/cpp/concept/InputIterator)
*
* \pre true
* \post El iterador \P{res} apunta al lugar-pasando-el-último de los
* registros de la tabla. Puede utilizarse para comparar con otro
* const_iterador_registros para saber si se llegó al final de la iteración.
*
* \complexity{\O(1)}
*/
const_iterador_registros registros_end() const;
private:
///////////////////////////////////////////////////////////////////////////////////////////////////
/** \name Representación
* rep: tabla \TO bool\n
* rep(t) \EQUIV
* * \LNOT \EMPTYSET?(_claves) \LAND
* * _claves \SUBSETEQ _campos \LAND
* * _campos = claves(_tipos) \LAND
* * \FORALL (r : registro) r \IN _registros \IMPLIES (
* * campos(r) = _campos
* * \FORALL (c : campo) c \IN _campos \IMPLIES
* Nat?(valor(c, r)) = Nat?(obtener(c, _tipos))
* * no se repiten claves \EQUIV
* \FORALL (r' : registro) r \IN (_registros - {r}) \IMPLIES
* \LNOT hayCoincidencia(r, _claves, _registros)
* * )
*
* abs: tabla \TO Tabla\n
* abs(t) \EQUIV t' \|
* * campos(t') = _campos \LAND
* * claves(t') = _claves \LAND
* * \FORALL (c : string) c \in _campos \IMPLIES tipoCampo(c, r') =
* Nat?(obtener(c, _tipos)) \LAND
* * registros(t') = _registros
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////
/** @{ */
linear_set<string> _claves;
linear_set<string> _campos;
linear_map<string, Dato> _tipos;
linear_set<Registro> _registros;
/** }@ */
};
bool operator==(const Tabla&, const Tabla&);
bool operator!=(const Tabla&, const Tabla&);
#include "const_iterador_registros.h"
#endif //TABLA_H
#include "const_iterador_registros.h"
Tabla::const_iterador_registros::const_iterador_registros(const const_iterador_registros& o_it) :
it_registro(o_it.it_registro) {}
const Registro& Tabla::const_iterador_registros::operator*() const {
return *it_registro;
}
const Registro *Tabla::const_iterador_registros::operator->() const {
return &(*it_registro);
}
Tabla::const_iterador_registros& Tabla::const_iterador_registros::operator++() {
++it_registro;
return *this;
}
bool Tabla::const_iterador_registros::operator==(const Tabla::const_iterador_registros& o_it) const {
return it_registro == o_it.it_registro;
}
bool Tabla::const_iterador_registros::operator!=(const Tabla::const_iterador_registros& o_it) const {
return not (it_registro == o_it.it_registro);
}
Tabla::const_iterador_registros::const_iterador_registros(const linear_set<Registro>::const_iterator _it_registro) :
it_registro(_it_registro) {}
#ifndef const_iterador_registros_h
#define const_iterador_registros_h
#include "Tabla.h"
/** @brief Iterador de los registros de una tabla */
class Tabla::const_iterador_registros {
public:
/**
* @brief Constructor por copia del iterador.
*
* \complexity{\O(1)}
*/
const_iterador_registros(const const_iterador_registros& o_it);
/**
* @brief Desreferencia el puntero
*
* El valor devuelto tiene aliasing dentro de la colección.
*
* \pre El iterador no debe estar en la posición pasando-el-último.
* \post El valor resultado es una referencia constante al valor apuntado.
*
* \complexity{\O(1)}
*/
const Registro& operator*() const;
/**
* @brief Operador flechita
*
* El valor devuelvo tiene aliasing dentro de la colección.
*
* \pre El iterador no debe estar en la posición pasando-el-último.
* \post El valor resultado es un puntero al valor apuntado.
*
* \complexity{\O(1)}
*/
const Registro *operator->() const;
/**
* @brief Avanza el iterador una posición.
*
* \pre El iterador no debe estar en la posición pasando-el-último.
* \post \P{res} es una referencia a \P{this}. \P{this} apunta a la posición
* siguiente.
*
* \complexity{\O(1)}
*/
const_iterador_registros& operator++();
/**
* @brief Comparación entre iteradores
*
* \pre ambos iteradores refieren a la misma colección
* \post true sii los iteradores apuntan al mismo elemento
*
* \complexity{\O(1)}
*/
bool operator==(const const_iterador_registros& o_it) const;
/**
* @brief Comparación entre iteradores
*
* \pre ambos iteradores refieren a la misma colección
* \post true sii los iteradores no apuntan al mismo elemento
*
* \complexity{\O(1)}
*/
bool operator!=(const const_iterador_registros& o_it) const;
private:
friend class Tabla;
const_iterador_registros(const linear_set<Registro>::const_iterator);
linear_set<Registro>::const_iterator it_registro;
};
#endif // const_iterador_registros_h
#ifndef linear_map_h
#define linear_map_h
#include <list>
#include <iostream>
using namespace std;
/**
* @brief Módulo diccionario con inserción en O(1)
*/
template<class K, class S>
class linear_map {
public:
using key_type = K;
using mapped_type = S;
using value_type = pair<const K, S>;
using size_type = size_t;
// Forward declaration
using iterator = typename list<pair<const K, S>>::iterator;
using const_iterator = typename list<pair<const K, S>>::const_iterator;
/**
* @brief Crea un diccionario vacio.
*
* \pre true
* \post \P{this} = vacio
*
* \complexity{\O(1)}
*/
linear_map();
/**
* @brief Constructor por copia
*
* \pre true
* \post \P{this} es una copia de other. No hay aliasing.
*
* \complexity{\O(#claves(ohter) * (copy(Clave) + copy(Significado)))}
*/
linear_map(const linear_map<K, S>& other);
/**
* @brief Define o redefine una relación en el diccionario.
*
* \pre d = \P{this}
* \post \P{this} = definir(d, \P1(v), \P2(v)) \LAND \P{res} es una tupla con
* el primer elemento un iterador a la relación definida y el segúndo elemento
* indica si \P1(v) no era clave del diccionario
*
* \complexity{\O(#claves(\P{this}) + copy(v))}
*/
pair<iterator, bool> insert(const value_type& v);
/**
* @brief Define una nueva relación en el diccionario.
*
* \pre d = \P{this} \LAND \LNOT def?(\P1(v), \P{this})
* \post \P{this} = definir(d, \P1(v), \P2(v)) \LAND \P{res} es un iterador
* que apunta a la relación recién definida
*
* \complexity{\O(copy(v))}
*/
iterator fast_insert(const value_type& v);
/**
* @brief Tamaño del diccionario.
*
* \pre true
* \post \P{res} = #clave(\P{this})
*
* \complexity{\O(1)}
*/
size_type size() const;
/**
* @brief Devuelve el significado relacionado con la clave.
*
* El significado se devuelve por referencia modificable.
*
* \pre def?(key, \P{this})
* \post \P{res} = obtener(\P{this}, k)
*/
S& at(const K& key);
/**
* @brief True si el diccionario está vacío.
*
* \pre true
* \post \P{res} = \EMPTYSET?(claves(\P{this}))
*
* \complexity{\O(1)}
*/
bool empty() const {
return _elems.empty();
}
/**
* @brief Devuelve un iterador relacionado a la clave buscada.
* End si no está definida.
*
* \pre true
* \post
* * def?(k, \P{this}) \IMPLIES \P1(\P{res}) = k \LAND
* \P2(\P{res}) = obtener(k, \P{this}) \LOR
* * \NEG def?(k, \P{this}) \IMPLIES \P{res} es end
*
* \complexity{\O(#claves(\P{this}))}
*/
iterator find(const K &k);
/**
* @brief Devuelve un iterador const relacionado a la clave buscada.
* End si no está definida.
*
* \pre true
* \post
* * def?(k, \P{this}) \IMPLIES \P1(\P{res}) = k \LAND
* \P2(\P{res}) = obtener(k, \P{this}) \LOR
* * \NEG def?(k, \P{this}) \IMPLIES \P{res} es end
*
* \complexity{\O(#claves(\P{this}))}
*/
const_iterator find(const K &k) const;
/**
* @brief Devuelve un iterador al inicio del diccionario.
*
* \pre true
* \post \P{res} apunta al inicio del diccionario
*
* \complexity{\O(1)}
*/
iterator begin();
/**
* @brief Devuelve un iterador a la posición pasando-el-último
*
* \pre true
* \post \P{res} apunta a la posición pasando-el-último
*
* \complexity{\O(1)}
*/
iterator end();
/**
* @brief Devuelve un iterador const al inicio del diccionario.
*
* \pre true
* \post \P{res} apunta al inicio del diccionario
*
* \complexity{\O(1)}
*/
const_iterator begin() const;
/**
* @brief Devuelve un iterador const a la posición pasando-el-último
*
* \pre true
* \post \P{res} apunta a la posición pasando-el-último
*
* \complexity{\O(1)}
*/
const_iterator end() const;
/**
* @brief Cantidad de apariciones de la clave.
*
* \pre true
* \post \P{res} == def?(\P{this}, k)
*
* \complexity{\O(n) * cmp(Clave)}
*/
size_t count(const K &k) const;
/**
* @brief Devuelve el significado relacionado con la clave.
*
* El significado se devuelve por referencia no-modificable.
*
* \pre def?(key, \P{this})
* \post \P{res} = obtener(\P{this}, k)
*/
const S& at(const K& key) const;
/**
* @brief Elimina el significado del diccionario. Devuelve la cantidad de
* elementos elminados.
*
* \pre d == \P{this} \LAND def?(key, \P{this})
* \post \P{this} == borrar(key, d)
*
* \complexity{\O(#claves(\P{this}))}
*/
size_type erase(const K& key);
/**
* @brief Operador asignación del diccionario
*
* \pre true
* \post \P{this} == other
*
* \complexity{\O(#claves(\P{this}) + #claves(other) * (copy(Clave) +
* copy(Significado)))}
*/
linear_map& operator=(const linear_map& other);
/**
* @brief True si los diccionarios son iguales.
*
* \complexity{\O(#claves(\P{this}) * #claves(other))}
*/
bool operator==(const linear_map& other) const;
private:
/**
* \name Representación:
*
* rep: linear_map(Clave, Significado) \TO bool\n
* rep(d) \EQUIV
* * \FORALL (t, t': tupla(Clave, Significado))
* (está?(t, _elems) \LAND está?(t', _elems)) \IMPLIES (t == t' \LOR \P1(t) != \P1(t'))
*
* abs: linear_map(Clave, Significado) \TO Dicc(Clave, Significado)\n
* abs(d) \EQUIV d' \|
* * \FORALL (c : Clave) def?(c, d') \IFF \EXISTS
* (t : tupla(Clave, Significado)) está?(t, _elems) \LAND P1(t) == c
* * \FORALL (t : tupla(Clave, Significado)) está?(t, _elems) \IMPLIES
* P2(t) == obtener(P1(t), d')
*/
/** @{ */
list<pair<const K, S>> _elems;
/** @} */
};
template<class K, class S>
std::ostream &operator<<(std::ostream& os, const linear_map<K, S> &m);
#include "linear_map.hpp"
#endif // linear_map_h
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment