diff --git a/CrossBench/main.cpp b/CrossBench/main.cpp index f5ad34d..8617b3a 100644 --- a/CrossBench/main.cpp +++ b/CrossBench/main.cpp @@ -1,6 +1,10 @@ -#include +#include "wx/wx.h" + +#include +#include #include "crossbasetypes.hpp" +#include "crossgen.hpp" /* To-Do: * Console app that runs generating of crosswords @@ -11,35 +15,42 @@ * 3. Dispersion */ -// application class -class wxMiniApp : public wxApp -{ -public: - // function called at the application initialization - virtual bool OnInit(); - - // event handler for button click - void OnClick(wxCommandEvent& event) { - GetTopWindow()->Close(); - } +static const wxCmdLineEntryDesc cmdLineDesc[] = { + { wxCMD_LINE_PARAM , wxT(""), wxT(""), wxT("cross_path"), + wxCMD_LINE_VAL_STRING }, + { wxCMD_LINE_PARAM, wxT(""), wxT(""), wxT("dict_path"), + wxCMD_LINE_VAL_STRING }, + { wxCMD_LINE_OPTION, wxT("c"), wxT("count"), wxT("times to run generation, default = 10") , + wxCMD_LINE_VAL_NUMBER }, + { wxCMD_LINE_SWITCH, wxT("h"), wxT("help"), wxT("show this help message"), + wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, + { wxCMD_LINE_NONE } }; -IMPLEMENT_APP(wxMiniApp); +int main(int argc, char **argv) { + wxInitializer wx_initializer; + if ( !wx_initializer ) { + fprintf(stderr, "Failed to initialize the wxWidgets library, aborting."); + return -1; + } + wxCmdLineParser cmd_parser(cmdLineDesc, argc, argv); + long run_count = 10; + wxString cross_path, dict_path; + switch ( cmd_parser.Parse() ) { + case -1: + return 0; + case 0: + cmd_parser.Found(wxT("count"), &run_count); + cross_path = cmd_parser.GetParam(0); + dict_path = cmd_parser.GetParam(1); + wxPrintf(wxT("cross_path = ") + cross_path + wxT("\n")); + wxPrintf(wxT("dict_path = ") + dict_path + wxT("\n")); + wxPrintf(wxT("run_count = %d\n"), run_count); + break; + default: + return 0; + } + -bool wxMiniApp::OnInit() -{ - // create a new frame and set it as the top most application window - SetTopWindow( new wxFrame( NULL, -1, wxT(""), wxDefaultPosition, wxSize( 100, 50) ) ); - - // create new button and assign it to the main frame - new wxButton( GetTopWindow(), wxID_EXIT, wxT("Click!") ); - - // connect button click event with event handler - Connect(wxID_EXIT, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxMiniApp::OnClick) ); - - // show main frame - GetTopWindow()->Show(); - - // enter the application's main loop - return true; + return 0; } diff --git a/CrossGen.workspace b/CrossGen.workspace index 1bcbf0a..18ecac8 100644 --- a/CrossGen.workspace +++ b/CrossGen.workspace @@ -1,13 +1,13 @@ - - + + - + - + diff --git a/Makefile b/Makefile index c1fa320..73e2032 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ .PHONY: clean All All: - @echo "----------Building project:[ wxCrossGen - Release ]----------" - @cd "wxCrossGen" && $(MAKE) -f "wxCrossGen.mk" + @echo "----------Building project:[ CrossBench - Debug ]----------" + @cd "CrossBench" && $(MAKE) -f "CrossBench.mk" clean: - @echo "----------Cleaning project:[ wxCrossGen - Release ]----------" - @cd "wxCrossGen" && $(MAKE) -f "wxCrossGen.mk" clean + @echo "----------Cleaning project:[ CrossBench - Debug ]----------" + @cd "CrossBench" && $(MAKE) -f "CrossBench.mk" clean diff --git a/src/crossgen.hpp b/src/crossgen.hpp index a6c71c2..81b8836 100644 --- a/src/crossgen.hpp +++ b/src/crossgen.hpp @@ -3,8 +3,11 @@ #include #include +#include +#include #include +#include #include "crossbasetypes.hpp" @@ -175,7 +178,7 @@ bool procCross(UsedWords used, AllWordsType &words, CurGridType grid, void generateCross(GridType &grid, const DictType &dict, std::vector &words_out){ AllWordsType words; - for (DictType::iterator it = dict.begin(); it != dict.end(); ++it){ + for (auto it = dict.begin(); it != dict.end(); ++it){ if (words.size() <= it->first.size()) words.resize(it->first.size() + 2); words.at(it->first.size()).push_back(it->first); diff --git a/wxCrossGen/wxCrossGen.mk b/wxCrossGen/wxCrossGen.mk index a362025..3ee55b8 100644 --- a/wxCrossGen/wxCrossGen.mk +++ b/wxCrossGen/wxCrossGen.mk @@ -2,18 +2,18 @@ ## Auto Generated makefile by CodeLite IDE ## any manual changes will be erased ## -## Release +## Debug ProjectName :=wxCrossGen -ConfigurationName :=Release +ConfigurationName :=Debug WorkspacePath := "/data/Sync/SyncProjects/CrossGen" ProjectPath := "/data/Sync/SyncProjects/CrossGen/wxCrossGen" -IntermediateDirectory :=../Release +IntermediateDirectory :=./Debug OutDir := $(IntermediateDirectory) CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Aleksey Lobanov -Date :=11/06/15 +Date :=12/06/15 CodeLitePath :="/home/alex/.codelite" LinkerName :=/usr/bin/g++-4.8 SharedObjectLinkerName :=/usr/bin/g++-4.8 -shared -fPIC @@ -28,14 +28,14 @@ LibraryPathSwitch :=-L PreprocessorSwitch :=-D SourceSwitch :=-c OutputFile :=$(IntermediateDirectory)/$(ProjectName).out -Preprocessors :=$(PreprocessorSwitch)NDEBUG +Preprocessors := ObjectSwitch :=-o ArchiveOutputSwitch := PreprocessOnlySwitch :=-E ObjectsFileList :="wxCrossGen.txt" PCHCompileFlags := MakeDirCommand :=mkdir -p -LinkOptions := -s $(shell wx-config --debug=no --libs --unicode=yes) +LinkOptions := $(shell wx-config --debug=yes --libs --unicode=yes) IncludePath := $(IncludeSwitch). $(IncludeSwitch)../src IncludePCH := RcIncludePath := @@ -50,8 +50,8 @@ LibPath := $(LibraryPathSwitch). AR := /usr/bin/ar rcu CXX := /usr/bin/g++-4.8 CC := /usr/bin/gcc-4.8 -CXXFLAGS := -std=c++11 -O2 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=no) $(Preprocessors) -CFLAGS := -O2 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=no) $(Preprocessors) +CXXFLAGS := -std=c++11 -g -O0 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=yes) $(Preprocessors) +CFLAGS := -g -O0 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=yes) $(Preprocessors) ASFLAGS := AS := /usr/bin/as @@ -79,7 +79,7 @@ $(OutputFile): $(IntermediateDirectory)/.d $(Objects) $(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions) $(IntermediateDirectory)/.d: - @test -d ../Release || $(MakeDirCommand) ../Release + @test -d ./Debug || $(MakeDirCommand) ./Debug PreBuild: @@ -101,6 +101,6 @@ $(IntermediateDirectory)/main.cpp$(PreprocessSuffix): main.cpp ## Clean ## clean: - $(RM) -r ../Release/ + $(RM) -r ./Debug/ diff --git a/wxCrossGen/wxCrossGen.txt b/wxCrossGen/wxCrossGen.txt index b7e8d8a..6716386 100644 --- a/wxCrossGen/wxCrossGen.txt +++ b/wxCrossGen/wxCrossGen.txt @@ -1 +1 @@ -../Release/main.cpp.o +./Debug/main.cpp.o