├── .gitignore ├── 1_c++ ├── 1_basicusage │ ├── MultiTestFuctions.cpp │ └── hello_cpp.cpp ├── 2_function │ └── function.cpp ├── 3_array_pointer │ └── .gitkeep ├── 4_class_oop │ └── .gitkeep ├── 5_file_io │ └── .gitkeep ├── 6_stl │ └── .gitkeep ├── CodePractice.md ├── README.md └── images │ ├── hanoi.gif │ └── multiTestFunctions.png ├── 2_datastructure_algorithm ├── .gitkeep ├── 0_string │ └── README.md ├── 1_array_sort │ └── README.md ├── 2_list │ ├── README.md │ └── images │ │ └── DL_List.jpg ├── 3_tree │ └── README.md ├── 4_graph │ └── README.md ├── 5_algorithm │ └── README.md └── README.md ├── 3_code_practice ├── README.md └── images │ └── overview.png ├── 4_projects ├── README.md ├── images │ ├── dynamic_pathplanning.gif │ ├── formation_1.gif │ ├── inverted_pendulum.png │ ├── inverted_pendulum_ori.png │ ├── lane_tracking.jpeg │ ├── lane_tracking.png │ ├── markerland.gif │ ├── shudu.jpeg │ ├── tetris.png │ ├── tetris_ori.png │ ├── uav_autolanding.png │ ├── uav_circle.jpeg │ ├── uav_flightformation-0.png │ ├── uav_flightformation.png │ └── wuziqi_cvc.gif ├── qt_demos │ ├── 1_simple_draw │ │ ├── README.md │ │ ├── images │ │ │ └── simple_draw.png │ │ ├── main.cpp │ │ ├── mainwindow.cpp │ │ ├── mainwindow.h │ │ └── simple_draw.pro │ ├── 2_draw_map │ │ ├── draw_map.cpp │ │ ├── draw_map.pro │ │ ├── map_viewer.cpp │ │ └── map_viewer.h │ └── README.md └── sfml_demos │ ├── 1_Tetris │ ├── README.md │ ├── images │ │ ├── background.png │ │ ├── frame.png │ │ ├── screen_shot.png │ │ └── tiles.png │ └── main.cpp │ ├── 2_Snake │ ├── README.md │ ├── images │ │ ├── green.png │ │ ├── red.png │ │ ├── screen_shot.png │ │ └── white.png │ └── main.cpp │ ├── 3_Chess │ ├── Connector.hpp │ ├── images │ │ ├── board.png │ │ ├── board0.png │ │ └── figures.png │ ├── main.cpp │ ├── stockfish │ └── stockfish.exe │ └── README.md ├── 5_advanced ├── 3_Library │ └── simple_lib │ │ ├── CMakeLists.txt │ │ ├── cmake │ │ ├── FindUtils.cmake │ │ └── PICMake.cmake │ │ ├── test_utils │ │ └── test_utils.cpp │ │ └── utils │ │ ├── CMakeLists.txt │ │ ├── gtest.cpp │ │ ├── gtest.h │ │ ├── utils.cpp │ │ └── utils.h ├── 4_DesignPattern_UML │ ├── DesignPattern_FullList │ │ ├── .gitignore │ │ ├── AbstractFactoryPattern │ │ │ ├── AbstractFactoryPattern.cpp │ │ │ ├── AbstractFactoryPattern.vcxproj │ │ │ └── AbstractFactoryPattern.vcxproj.filters │ │ ├── AdapterPattern │ │ │ ├── AdapterPattern.cpp │ │ │ ├── AdapterPattern.vcxproj │ │ │ └── AdapterPattern.vcxproj.filters │ │ ├── BridgePattern │ │ │ ├── BridgePattern.cpp │ │ │ ├── BridgePattern.vcxproj │ │ │ └── BridgePattern.vcxproj.filters │ │ ├── BuilderPattern │ │ │ ├── BuilderPattern.cpp │ │ │ ├── BuilderPattern.vcxproj │ │ │ └── BuilderPattern.vcxproj.filters │ │ ├── CMakeLists.txt │ │ ├── ChainOfResponsibilityPattern │ │ │ ├── ChainOfResponsibilityPattern.cpp │ │ │ ├── ChainOfResponsibilityPattern.vcxproj │ │ │ └── ChainOfResponsibilityPattern.vcxproj.filters │ │ ├── CommandPattern │ │ │ ├── CommandPattern.cpp │ │ │ ├── CommandPattern.vcxproj │ │ │ └── CommandPattern.vcxproj.filters │ │ ├── CompositePattern │ │ │ ├── CompositePattern.cpp │ │ │ ├── CompositePattern.vcxproj │ │ │ └── CompositePattern.vcxproj.filters │ │ ├── DecoratorPattern │ │ │ ├── DecoratorPattern.cpp │ │ │ ├── DecoratorPattern.vcxproj │ │ │ └── DecoratorPattern.vcxproj.filters │ │ ├── DesignPattern.sln │ │ ├── FacadePattern │ │ │ ├── FacadePattern.cpp │ │ │ ├── FacadePattern.vcxproj │ │ │ └── FacadePattern.vcxproj.filters │ │ ├── FactoryPattern │ │ │ ├── FactoryPattern.cpp │ │ │ ├── FactoryPattern.vcxproj │ │ │ └── FactoryPattern.vcxproj.filters │ │ ├── FlyweightPattern │ │ │ ├── FlyweightPattern.cpp │ │ │ ├── FlyweightPattern.vcxproj │ │ │ └── FlyweightPattern.vcxproj.filters │ │ ├── InterpreterPattern │ │ │ ├── InterpreterPattern.cpp │ │ │ ├── InterpreterPattern.vcxproj │ │ │ └── InterpreterPattern.vcxproj.filters │ │ ├── IteratorPattern │ │ │ ├── Aggregate.cpp │ │ │ ├── Aggregate.h │ │ │ ├── Iterator.cpp │ │ │ ├── Iterator.h │ │ │ ├── IteratorPattern.cpp │ │ │ ├── IteratorPattern.vcxproj │ │ │ └── IteratorPattern.vcxproj.filters │ │ ├── LICENSE │ │ ├── MediatorPattern │ │ │ ├── MediatorPattern.cpp │ │ │ ├── MediatorPattern.vcxproj │ │ │ └── MediatorPattern.vcxproj.filters │ │ ├── MementoPattern │ │ │ ├── MementoPattern.cpp │ │ │ ├── MementoPattern.vcxproj │ │ │ └── MementoPattern.vcxproj.filters │ │ ├── ObserverPattern │ │ │ ├── Observer.cpp │ │ │ ├── Observer.h │ │ │ ├── ObserverPattern.cpp │ │ │ ├── ObserverPattern.vcxproj │ │ │ ├── ObserverPattern.vcxproj.filters │ │ │ ├── Subject.cpp │ │ │ └── Subject.h │ │ ├── PrototypePattern │ │ │ ├── PrototypePattern.cpp │ │ │ ├── PrototypePattern.vcxproj │ │ │ └── PrototypePattern.vcxproj.filters │ │ ├── ProxyPattern │ │ │ ├── ProxyPattern.cpp │ │ │ ├── ProxyPattern.vcxproj │ │ │ └── ProxyPattern.vcxproj.filters │ │ ├── README.md │ │ ├── SingletonPattern │ │ │ ├── SingletonPattern.cpp │ │ │ ├── SingletonPattern.vcxproj │ │ │ └── SingletonPattern.vcxproj.filters │ │ ├── StatePattern │ │ │ ├── StatePattern.cpp │ │ │ ├── StatePattern.vcxproj │ │ │ └── StatePattern.vcxproj.filters │ │ ├── StrategyPattern │ │ │ ├── StrategyPattern.cpp │ │ │ ├── StrategyPattern.vcxproj │ │ │ └── StrategyPattern.vcxproj.filters │ │ ├── TemplatePattern │ │ │ ├── TemplatePattern.cpp │ │ │ ├── TemplatePattern.vcxproj │ │ │ └── TemplatePattern.vcxproj.filters │ │ └── VisitorPattern │ │ │ ├── Element.cpp │ │ │ ├── Element.h │ │ │ ├── Visitor.cpp │ │ │ ├── Visitor.h │ │ │ ├── VisitorPattern.cpp │ │ │ ├── VisitorPattern.vcxproj │ │ │ └── VisitorPattern.vcxproj.filters │ ├── README.md │ ├── sample_messenger │ │ ├── Messenger.h │ │ ├── Svar.h │ │ ├── complex_demo.cpp │ │ ├── messenger_demo.pro │ │ └── simple_demo.cpp │ ├── sample_oo-design │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── GSLAM │ │ │ ├── Camera.h │ │ │ ├── Dataset.h │ │ │ ├── Display.h │ │ │ ├── Estimator.h │ │ │ ├── FileResource.h │ │ │ ├── GImage.h │ │ │ ├── GPS.h │ │ │ ├── GSLAM.h │ │ │ ├── Glog.h │ │ │ ├── HashMap.h │ │ │ ├── Map.h │ │ │ ├── Matrix.h │ │ │ ├── Messenger.h │ │ │ ├── NodeGL.h │ │ │ ├── Optimizer.h │ │ │ ├── Point.h │ │ │ ├── Registry.h │ │ │ ├── SE3.h │ │ │ ├── SIM3.h │ │ │ ├── SO3.h │ │ │ ├── SharedLibrary.h │ │ │ ├── Svar.h │ │ │ ├── Timer.h │ │ │ ├── Undistorter.h │ │ │ ├── Vocabulary.h │ │ │ └── filesystem.hpp │ │ ├── README.md │ │ ├── cmake │ │ │ ├── FindOpenCV.cmake │ │ │ ├── FindPoco.cmake │ │ │ ├── PICMake.cmake │ │ │ ├── linux64 │ │ │ │ ├── FindGLEW.cmake │ │ │ │ ├── FindQt.cmake │ │ │ │ ├── FindSystem.cmake │ │ │ │ └── glew-1.13.0 │ │ │ │ │ ├── include │ │ │ │ │ └── GL │ │ │ │ │ │ ├── glew.h │ │ │ │ │ │ ├── glxew.h │ │ │ │ │ │ └── wglew.h │ │ │ │ │ └── lib │ │ │ │ │ └── libGLEW.a │ │ │ └── vs2015x64 │ │ │ │ ├── FindGLEW.cmake │ │ │ │ ├── FindGSLAM.cmake.in │ │ │ │ ├── FindOPENGL.cmake │ │ │ │ ├── FindQt.cmake │ │ │ │ ├── FindSystem.cmake │ │ │ │ ├── glew-1.13.0 │ │ │ │ ├── include │ │ │ │ │ └── GL │ │ │ │ │ │ ├── glew.h │ │ │ │ │ │ ├── glxew.h │ │ │ │ │ │ └── wglew.h │ │ │ │ └── lib │ │ │ │ │ └── Release │ │ │ │ │ ├── Win32 │ │ │ │ │ ├── glew32.exp │ │ │ │ │ └── glew32.lib │ │ │ │ │ └── x64 │ │ │ │ │ └── libglew32.lib │ │ │ │ ├── shared_export.map │ │ │ │ └── static_export.sym │ │ └── src │ │ │ ├── comm.h │ │ │ ├── control.h │ │ │ ├── datalink_protocol.h │ │ │ ├── main.cpp │ │ │ ├── simulation.h │ │ │ └── uav.h │ ├── sample_parameters │ │ ├── Default.json │ │ ├── Makefile │ │ ├── ParameterDemo.pro │ │ └── src │ │ │ ├── ParameterDemo.cpp │ │ │ └── Svar.h │ ├── sample_plugin │ │ ├── Plugin.pro │ │ ├── README.md │ │ ├── images │ │ │ ├── plugin_impl.png │ │ │ └── plugin_use.png │ │ └── src │ │ │ ├── PluginDef.h │ │ │ ├── PluginDemo.cpp │ │ │ ├── PluginImplA.cpp │ │ │ ├── PluginImplB.cpp │ │ │ └── Svar.h │ └── svar_module │ │ ├── README.md │ │ ├── other │ │ ├── redefine │ │ │ ├── CMakeLists.txt │ │ │ ├── cmake │ │ │ │ ├── FindLTO.cmake │ │ │ │ ├── FindOPENGL.cmake │ │ │ │ ├── FindQt.cmake │ │ │ │ ├── FindSystem.cmake │ │ │ │ ├── FindTBB.cmake │ │ │ │ ├── PICMake.cmake │ │ │ │ └── PICMake.cmake.in │ │ │ └── src │ │ │ │ ├── a.cpp │ │ │ │ └── b.cpp │ │ ├── redefine_b │ │ │ ├── CMakeLists.txt │ │ │ ├── cmake │ │ │ │ ├── FindLTO.cmake │ │ │ │ ├── FindOPENGL.cmake │ │ │ │ ├── FindQt.cmake │ │ │ │ ├── FindSystem.cmake │ │ │ │ ├── FindTBB.cmake │ │ │ │ ├── PICMake.cmake │ │ │ │ └── PICMake.cmake.in │ │ │ └── src │ │ │ │ ├── a.cpp │ │ │ │ ├── b.cpp │ │ │ │ ├── bash.sh │ │ │ │ ├── libA.so │ │ │ │ ├── libB.so │ │ │ │ ├── main │ │ │ │ └── main.cpp │ │ └── test │ │ │ ├── CMakeLists.txt │ │ │ ├── cmake │ │ │ ├── FindLTO.cmake │ │ │ ├── FindOPENGL.cmake │ │ │ ├── FindQt.cmake │ │ │ ├── FindSystem.cmake │ │ │ ├── FindTBB.cmake │ │ │ ├── PICMake.cmake │ │ │ └── PICMake.cmake.in │ │ │ └── src │ │ │ ├── Glog.h │ │ │ ├── Messenger.h │ │ │ ├── Svar.h │ │ │ ├── add.cpp │ │ │ └── useadd.cpp │ │ ├── svar_basic │ │ ├── CMakeLists.txt │ │ ├── cmake │ │ │ ├── FindLTO.cmake │ │ │ ├── FindOPENGL.cmake │ │ │ ├── FindQt.cmake │ │ │ ├── FindSystem.cmake │ │ │ ├── FindTBB.cmake │ │ │ ├── PICMake.cmake │ │ │ └── PICMake.cmake.in │ │ └── src │ │ │ ├── Svar.h │ │ │ └── main.cpp │ │ └── svar_plugin │ │ ├── CMakeLists.txt │ │ ├── cmake │ │ ├── FindLTO.cmake │ │ ├── FindOPENGL.cmake │ │ ├── FindQt.cmake │ │ ├── FindSystem.cmake │ │ ├── FindTBB.cmake │ │ ├── PICMake.cmake │ │ └── PICMake.cmake.in │ │ └── src │ │ ├── Svar.h │ │ ├── a.cpp │ │ ├── b.cpp │ │ └── main.cpp ├── 5_MultiThread │ ├── README.md │ ├── coroutine │ │ ├── CMakeLists.txt │ │ ├── coroutine.h │ │ └── demo_coroutine.cpp │ ├── process_pipe │ │ └── pipe_rw.cpp │ └── producer_consumer │ │ ├── producer_consumer.cpp │ │ └── producer_consumer.pro ├── 6_Debug │ └── backward │ │ ├── README.md │ │ ├── backward.cpp │ │ ├── backward.hpp │ │ └── test_backward.cpp ├── README.md └── programming_standard │ ├── Google_Cpp_Style_guide_CN.pdf │ ├── Google_Cpp_Style_guide_CN.png │ └── README.md ├── 6_adv_projects └── README.md ├── 6_tools ├── README.md ├── cmake │ ├── 1_CMake │ │ ├── simple_exe │ │ │ ├── CMakeLists.txt │ │ │ └── src │ │ │ │ └── simple_exe.cpp │ │ ├── simple_sharedlib │ │ │ ├── CMakeLists.txt │ │ │ ├── src │ │ │ │ └── simple_sharedlib.cpp │ │ │ └── utils │ │ │ │ ├── utils.cpp │ │ │ │ └── utils.h │ │ └── simple_staticlib │ │ │ ├── CMakeLists.txt │ │ │ ├── src │ │ │ └── simple_staticlib.cpp │ │ │ └── utils │ │ │ ├── utils.cpp │ │ │ └── utils.h │ ├── 2_PICMake │ │ ├── simple_exe │ │ │ ├── CMakeLists.txt │ │ │ ├── PICMake.cmake │ │ │ └── src │ │ │ │ └── simple_exe.cpp │ │ ├── simple_sharedlib │ │ │ ├── CMakeLists.txt │ │ │ ├── cmake │ │ │ │ ├── FindUtils.cmake │ │ │ │ └── PICMake.cmake │ │ │ ├── src │ │ │ │ └── simple_sharedlib.cpp │ │ │ └── utils │ │ │ │ ├── utils.cpp │ │ │ │ └── utils.h │ │ └── simple_staticlib │ │ │ ├── CMakeLists.txt │ │ │ ├── cmake │ │ │ ├── FindUtils.cmake │ │ │ └── PICMake.cmake │ │ │ ├── src │ │ │ └── simple_staticlib.cpp │ │ │ └── utils │ │ │ ├── utils.cpp │ │ │ └── utils.h │ ├── CMake变量.md │ ├── CMake常用指令.md │ ├── PICMake.md │ ├── README.md │ ├── summercamp │ │ ├── t1 │ │ │ ├── CMakeLists.txt │ │ │ └── main.c │ │ ├── t2 │ │ │ ├── .idea │ │ │ │ ├── .name │ │ │ │ ├── codeStyles │ │ │ │ │ └── Project.xml │ │ │ │ ├── dictionaries │ │ │ │ │ └── oem.xml │ │ │ │ ├── misc.xml │ │ │ │ ├── modules.xml │ │ │ │ ├── t2.iml │ │ │ │ └── workspace.xml │ │ │ ├── CMakeLists.txt │ │ │ ├── README.md │ │ │ ├── doc │ │ │ │ └── hello.txt │ │ │ ├── runhello.sh │ │ │ └── src │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── main.c │ │ ├── t3 │ │ │ ├── .idea │ │ │ │ ├── .name │ │ │ │ ├── codeStyles │ │ │ │ │ └── Project.xml │ │ │ │ ├── dictionaries │ │ │ │ │ └── oem.xml │ │ │ │ ├── misc.xml │ │ │ │ ├── modules.xml │ │ │ │ ├── t3.iml │ │ │ │ └── workspace.xml │ │ │ ├── CMakeLists.txt │ │ │ └── lib │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── hello.c │ │ │ │ └── hello.h │ │ ├── t4 │ │ │ ├── .idea │ │ │ │ ├── .name │ │ │ │ ├── codeStyles │ │ │ │ │ └── Project.xml │ │ │ │ ├── dictionaries │ │ │ │ │ └── oem.xml │ │ │ │ ├── misc.xml │ │ │ │ ├── modules.xml │ │ │ │ ├── t4.iml │ │ │ │ └── workspace.xml │ │ │ ├── CMakeLists.txt │ │ │ ├── cmake │ │ │ │ └── FindOpenCV.cmake │ │ │ ├── main.cpp │ │ │ └── timg.jpeg │ │ └── test │ │ │ ├── CMakeLists.txt │ │ │ ├── data.txt │ │ │ └── main.c │ ├── 单个源文件下Cmake.md │ ├── 工程下Cmake.md │ ├── 模块的使用和自定义模块.md │ └── 静态库与动态库构建与安装.md ├── debug │ ├── README.md │ ├── backtrace │ │ ├── Glog.h │ │ ├── Svar.h │ │ ├── backtrace.pro │ │ ├── test_backtrace.cpp │ │ ├── utils_debug.cpp │ │ └── utils_debug.h │ ├── dbg-macro │ │ ├── README.md │ │ ├── dbg.h │ │ └── images │ │ │ └── dbg-macro.png │ ├── images │ │ ├── backtrace_demo1.png │ │ ├── backtrace_demo2.png │ │ ├── qtcreator_debug_01.png │ │ ├── qtcreator_debug_02.png │ │ ├── qtcreator_debug_03.png │ │ ├── qtcreator_debug_04.png │ │ ├── qtcreator_debug_05.png │ │ └── qtcreator_debug_06.png │ ├── log │ │ ├── Glog.h │ │ ├── Svar.h │ │ ├── debug_config.cpp │ │ ├── debug_config.h │ │ ├── fmt_format.cpp │ │ ├── fmt_format.h │ │ ├── fmt_posix.cpp │ │ ├── fmt_posix.h │ │ ├── log.pro │ │ ├── test_log.cpp │ │ ├── utils_debug.cpp │ │ └── utils_debug.h │ └── module_test │ │ ├── demo_test.cpp │ │ ├── demo_test_main.cpp │ │ ├── gtest.cpp │ │ └── gtest.h ├── flickers │ ├── flickers.md │ └── system │ │ ├── lightdm.conf │ │ └── supervisor │ │ ├── configSupervisor.sh │ │ ├── supervisord.conf │ │ └── supervisord.service ├── git │ ├── Git_remote_branch.pdf │ ├── Git使用教程_PILAB.pdf │ ├── Git教程.pdf │ ├── HowToForkClone.md │ ├── HowToPullRequest.md │ ├── README.md │ ├── git-cheatsheet.pdf │ ├── git-cheatsheet_cn.jpg │ ├── git-tips.md │ ├── gitee_addmember.md │ ├── gitignore.txt │ ├── git简明教程.md │ └── pic_git │ │ ├── git1.png │ │ ├── git2.png │ │ ├── git3.png │ │ ├── git4.png │ │ ├── git5.png │ │ ├── git6.png │ │ ├── git7.png │ │ ├── git_clone_code.png │ │ ├── git_pull_request1.png │ │ ├── git_pull_request2.png │ │ ├── gitee_addmember1.png │ │ ├── gitee_addmember2.png │ │ ├── gitee_addmember3.png │ │ └── how_to_fork.png ├── latex │ ├── Readme.md │ └── src │ │ ├── My_xelatex │ │ ├── missfont.log │ │ ├── nwpuname.png │ │ ├── tmp.aux │ │ ├── tmp.log │ │ ├── tmp.pdf │ │ ├── tmp.synctex.gz │ │ ├── tmp.tex │ │ └── tmp.toc │ │ └── hello_world │ │ ├── document.aux │ │ ├── document.log │ │ ├── document.pdf │ │ ├── document.synctex.gz │ │ ├── document.tex │ │ └── document.toc ├── linux │ ├── README.md │ ├── docs │ │ ├── Bash-Beginners-Guide.pdf │ │ ├── Linux_Complete_Command_Line.pdf │ │ ├── bashref.pdf │ │ ├── scripts │ │ │ ├── StartWork.sh │ │ │ ├── auto_setup_mint_18.sh │ │ │ ├── demo_lml_starter.sh │ │ │ └── sysReinstall.sh │ │ ├── sysReinstall.sh │ │ ├── ubuntu命令行简明教程.pdf │ │ ├── unixtoolbox.pdf │ │ ├── unixtoolbox_cn.pdf │ │ └── 鸟哥的Linux私房菜基础篇-第三版.pdf │ ├── images │ │ ├── LinuxMint_Software_Source1.png │ │ ├── LinuxMint_Software_Source2.png │ │ └── man_ls.png │ └── learn_bash.md ├── markdown │ ├── README.md │ ├── README_排版效果.pdf │ ├── class │ │ ├── README.md │ │ └── pictures │ │ │ ├── an255.jpeg │ │ │ ├── dashixiong.jpg │ │ │ ├── kpln.jpg │ │ │ ├── markdown 即时渲染.gif │ │ │ ├── typora.png │ │ │ ├── 图形环境下 IDE 总揽.png │ │ │ └── 穿vim的小孩.jpg │ ├── docs │ │ └── Markdown 语法手册.pdf │ └── practice │ │ ├── Markdown practice.md │ │ └── pics │ │ ├── dcircuit_1.png │ │ ├── dcircuit_2.png │ │ └── excircuit.png └── qt │ ├── README.md │ └── images │ └── qt_win_select_components.png ├── 7_adv_c++ ├── README.md └── books │ ├── 《现代C++教程(中文版)》.pdf │ └── 《现代C++教程(英文版)》.pdf ├── 8_other ├── Compiler.md ├── ComputerArch_EmbeddedSystem.md ├── Network.md ├── OperatingSystem.md └── images │ └── compiler.jpg ├── LICENSE ├── Progress.md ├── README.md ├── Target.md ├── demo_code ├── 1_MultiTestFunctions │ └── MultiTestFuctions.cpp └── README.md └── images ├── learn_programming.png ├── study-methods.pptx └── suggested_progress.png /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *user 3 | a.out 4 | *.exe 5 | settings.json 6 | .vscode 7 | build* 8 | -------------------------------------------------------------------------------- /1_c++/1_basicusage/hello_cpp.cpp: -------------------------------------------------------------------------------- 1 | // Simplest C++ program 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | cout << "hello world!\n"; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /1_c++/2_function/function.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int print_message(const char *msg) 4 | { 5 | printf("message: %s\n", msg); 6 | } 7 | 8 | int pass_argument(int a, int b) 9 | { 10 | printf("a = %d, b = %d\n", a, b); 11 | return 0; 12 | } 13 | 14 | 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | char buf[256]; 19 | 20 | for(int i=0; i<10; i++) 21 | { 22 | sprintf(buf, "[%4d]", i); 23 | print_message(buf); 24 | } 25 | 26 | pass_argument(10, 20); 27 | 28 | return 0; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /1_c++/3_array_pointer/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/1_c++/3_array_pointer/.gitkeep -------------------------------------------------------------------------------- /1_c++/4_class_oop/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/1_c++/4_class_oop/.gitkeep -------------------------------------------------------------------------------- /1_c++/5_file_io/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/1_c++/5_file_io/.gitkeep -------------------------------------------------------------------------------- /1_c++/6_stl/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/1_c++/6_stl/.gitkeep -------------------------------------------------------------------------------- /1_c++/README.md: -------------------------------------------------------------------------------- 1 | # C++基础 2 | 3 | ## 1. 学习内容 4 | 学习C++的基本语法,练习编写基本的程序,包括: 5 | * 基本的用法,变量、循环、判断、打印 6 | * 函数的定义、调用 7 | * 数组、指针 8 | * 类,面向对象编程 9 | * 文件、IO操作 10 | * STL标准模板类,模板 11 | * 如何使用IDE环境编写、调试程序;或者在Linux下用GCC编译器编译程序 12 | 13 | ## 2. 要求 14 | 请将练习的程序按照类别保存到对应的目录里。编程练习题目可以参考[《编程练习题》](CodePractice.md) 15 | 16 | 17 | ## 3. 学习资料 18 | - 资料(可以使用在线的教程,或者自己找比较合适的): 19 | - [C++ 教程](http://www.runoob.com/cplusplus/cpp-tutorial.html) ,通过这个教程快速学会C++的语法等。 20 | - 如果对自己有更高的要求,可以学习[C++ Primer](https://www.zhihu.com/question/32087709)。不过最好还是用上面普通的教程先把基础知识学好之后,把Stage4的小项目做完之后,再学习C++ Primer更有效率。 21 | - 通过[Google 开源项目风格指南](https://zh-google-styleguide.readthedocs.io/en/latest/contents/)规范自己写C++时的命名规范。 22 | 23 | ## 4. 小技巧 24 | ### 4.1 如何在一个程序里,写多个测试、验证代码 25 | 具体可以参考[多个测试函数例子](1_basicusage/MultiTestFuctions.cpp),里面的用法。这样让程序保持清晰、易懂。 26 | 27 | ![multiTestFunctions](images/multiTestFunctions.png) 28 | 29 | 30 | 31 | ## 5. 参考资料 32 | 33 | ### 5.1 教程 34 | 35 | * [C++基础入门](https://gitee.com/andy-upp/linux-cpp-tutorial/blob/master/01.C++%E5%9F%BA%E7%A1%80%E6%95%99%E7%A8%8B/01.C++%20%E5%9F%BA%E7%A1%80%E5%85%A5%E9%97%A8/C++%E5%9F%BA%E7%A1%80%E5%85%A5%E9%97%A8%E8%AE%B2%E4%B9%89/C++%E5%9F%BA%E7%A1%80%E5%85%A5%E9%97%A8.md) 36 | * [C++核心编程](https://gitee.com/andy-upp/linux-cpp-tutorial/blob/master/01.C++%E5%9F%BA%E7%A1%80%E6%95%99%E7%A8%8B/03.C++%E6%A0%B8%E5%BF%83%E7%BC%96%E7%A8%8B/%E8%AE%B2%E4%B9%89/C++%E6%A0%B8%E5%BF%83%E7%BC%96%E7%A8%8B.md) 37 | * [C++提高编程](https://gitee.com/andy-upp/linux-cpp-tutorial/blob/master/01.C++%E5%9F%BA%E7%A1%80%E6%95%99%E7%A8%8B/05.C++%E6%8F%90%E9%AB%98%E7%BC%96%E7%A8%8B/%E8%AE%B2%E4%B9%89/C++%E6%8F%90%E9%AB%98%E7%BC%96%E7%A8%8B.md) 38 | 39 | ### 5.2 英文的编程练习题 40 | 41 | * https://www.w3resource.com/cpp-exercises/basic/index.php 42 | * https://edabit.com/challenges/cpp -------------------------------------------------------------------------------- /1_c++/images/hanoi.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/1_c++/images/hanoi.gif -------------------------------------------------------------------------------- /1_c++/images/multiTestFunctions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/1_c++/images/multiTestFunctions.png -------------------------------------------------------------------------------- /2_datastructure_algorithm/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/2_datastructure_algorithm/.gitkeep -------------------------------------------------------------------------------- /2_datastructure_algorithm/0_string/README.md: -------------------------------------------------------------------------------- 1 | # 字符串 2 | 3 | 字符串是程序中经常用到的一类数据结构,用来表示一组字符组成的单词或者句子,可以用来表示文件路径、需要处理的文本信息等。 4 | 5 | ## 1. 无重复字符的最长子串 6 | 7 | 给定一个字符串,请你找出其中不含有重复字符的 **最长子串** 的长度。 8 | 9 | 示例 1: 10 | ``` 11 | 输入: "abcabcbb" 12 | 输出: 3 13 | 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。 14 | ``` 15 | 16 | 示例 2: 17 | ``` 18 | 输入: "bbbbb" 19 | 输出: 1 20 | 解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。 21 | ``` 22 | 23 | 示例 3: 24 | ``` 25 | 输入: "pwwkew" 26 | 输出: 3 27 | 解释: 因为无重复字符的最长子串是 "wke",所以其长度为 3。 28 | 请注意,你的答案必须是 子串 的长度,"pwke" 是一个子序列,不是子串。 29 | ``` 30 | 31 | 32 | ## 2. 最长公共前缀 33 | 编写一个函数来查找字符串数组中的最长公共前缀。 34 | 35 | 如果不存在公共前缀,返回空字符串 `""`。 36 | 37 | 示例 1: 38 | ``` 39 | 输入: ["flower","flow","flight"] 40 | 输出: "fl" 41 | ``` 42 | 43 | 示例 2: 44 | ``` 45 | 输入: ["dog","racecar","car"] 46 | 输出: "" 47 | 解释: 输入不存在公共前缀。 48 | ``` 49 | 50 | **说明:** 51 | 52 | 所有输入只包含小写字母 a-z 。 53 | 54 | 55 | ## 3. 字符串的排列 56 | 57 | 给定两个字符串 s1 和 s2,写一个函数来判断 s2 是否包含 s1 的排列。 58 | 59 | 换句话说,第一个字符串的排列之一是第二个字符串的子串。 60 | 61 | 示例1: 62 | ``` 63 | 输入: s1 = "ab" s2 = "eidbaooo" 64 | 输出: True 65 | 解释: s2 包含 s1 的排列之一 ("ba"). 66 | ``` 67 | 68 | 示例2: 69 | ``` 70 | 输入: s1= "ab" s2 = "eidboaoo" 71 | 输出: False 72 | ``` 73 | 74 | **注意:** 75 | * 输入的字符串只包含小写字母 76 | * 两个字符串的长度都在 [1, 10,000] 之间 77 | 78 | 79 | ## 4. 翻转字符串里的单词 80 | 给定一个字符串,逐个翻转字符串中的每个单词。 81 | 82 | 83 | 示例 1: 84 | ``` 85 | 输入: "the sky is blue" 86 | 输出: "blue is sky the" 87 | ``` 88 | 89 | 示例 2: 90 | ``` 91 | 输入: " hello world! " 92 | 输出: "world! hello" 93 | 解释: 输入字符串可以在前面或者后面包含多余的空格,但是反转后的字符不能包括。 94 | ``` 95 | 96 | 示例 3: 97 | ``` 98 | 输入: "a good example" 99 | 输出: "example good a" 100 | 解释: 如果两个单词间有多余的空格,将反转后单词间的空格减少到只含一个。 101 | ``` 102 | 103 | **说明:** 104 | * 无空格字符构成一个单词。 105 | * 输入字符串可以在前面或者后面包含多余的空格,但是反转后的字符不能包括。 106 | * 如果两个单词间有多余的空格,将反转后单词间的空格减少到只含一个。 107 | 108 | -------------------------------------------------------------------------------- /2_datastructure_algorithm/2_list/README.md: -------------------------------------------------------------------------------- 1 | # 链表 2 | 3 | 链表(linked-list),就是线性表的链式存储方式。链表的内存是不连续的,前一个元素存储地址的下一个地址中存储的不一定是下一个元素。链表通过一个指向下一个元素地址的引用将链表中的元素串起来。 4 | 5 | 6 | ## 1. 合并两个有序链表 7 | 8 | 将两个有序链表合并为一个新的有序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 9 | 10 | 示例: 11 | ``` 12 | 输入: 13 | 链表1: 1->2->4 14 | 链表2: 1->3->4 15 | 16 | 输出: 17 | 1->1->2->3->4->4 18 | ``` 19 | 20 | 21 | ## 2. 反转链表 22 | 23 | 反转一个单链表。 24 | 25 | 示例: 26 | ``` 27 | 输入: 28 | 1->2->3->4->5->NULL 29 | 30 | 输出: 31 | 5->4->3->2->1->NULL 32 | ``` 33 | 34 | 35 | ## 3. 查找链表中倒数第k个结点 36 | 37 | 输入一个单向链表,输出该链表中倒数第k个结点。链表的倒数第0个结点为链表的尾指针。 38 | 39 | 示例: 40 | ``` 41 | 输入: 42 | 5->6->2->10->3->NULL 43 | 44 | 要求:倒数第2个元素 45 | 46 | 输出: 47 | 10 48 | ``` 49 | 50 | 进阶: 51 | * 考虑是否能对链表遍历一遍完成任务? 52 | 53 | 54 | ## 4. 双向循环链表的队列 55 | 56 | 构建双向循环链表,其中的存储的数据为整数,按照大小顺序保存,需要有一个指针记录队列的首位置。 57 | 58 | 要求: 59 | * 编写插入函数:新的数据插入的时候,自动按照新数据的大小插入到正确的位置 60 | * 编写取出函数:取出当前双向循环链表中最小的那个数据 61 | 62 | 63 | 注:双向链表在每一个节点添加了一个指向前驱结点的指针;双向循环链表是将最后一个结点的后继指针指向头结点,表头节点的前驱指针指向最后一个节点。示意图如下图所示: 64 | ![双向循环链表](images/DL_List.jpg) 65 | 66 | 67 | 示例: 68 | ``` 69 | 按照插入顺序插入双向环形链表: 70 | 3, 10, 54, 23, 50, 8, 2, 40 71 | 72 | 构建的双向循环链表为: 73 | ---------------------------------- 74 | | | 75 | 2 = 3 = 8 = 10 = 23 = 40 = 50 = 54 76 | | | 77 | ---------------------------------- 78 | 79 | 取出数据的顺序为: 80 | 2, 3, 8, 10, 23, 40, 50, 54 81 | ``` 82 | 83 | -------------------------------------------------------------------------------- /2_datastructure_algorithm/2_list/images/DL_List.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/2_datastructure_algorithm/2_list/images/DL_List.jpg -------------------------------------------------------------------------------- /2_datastructure_algorithm/4_graph/README.md: -------------------------------------------------------------------------------- 1 | # 图 2 | 3 | 一个图就是一些顶点的集合,这些顶点通过一系列边结对(连接)。顶点用圆圈表示,边就是这些圆圈之间的连线。顶点之间通过边连接。 4 | 5 | 6 | 7 | ## 1. 课程表 8 | 9 | 现在你总共有 `n` 门课需要选,记为 `0` 到 `n-1`。 10 | 11 | 在选修某些课程之前需要一些先修课程。 例如,想要学习课程 `0` ,你需要先完成课程 `1` ,我们用一个匹配来表示他们: `[0,1]` 12 | 13 | 给定课程总量以及它们的先决条件,判断是否可能完成所有课程的学习? 14 | 15 | 示例 1: 16 | ``` 17 | 输入: 18 | 2, [[1,0]] 19 | 20 | 输出: 21 | true 22 | 23 | 解释: 总共有 2 门课程。学习课程 1 之前,你需要完成课程 0。所以这是可能的。 24 | ``` 25 | 26 | 示例 2: 27 | ``` 28 | 输入: 29 | 2, [[1,0],[0,1]] 30 | 31 | 输出: 32 | false 33 | 34 | 解释: 总共有 2 门课程。学习课程 1 之前,你需要先完成​课程 0;并且学习课程 0 之前,你还应先完成课程 1。这是不可能的。 35 | ``` 36 | 37 | 说明: 38 | * 输入的先决条件是由边缘列表表示的图形,而不是邻接矩阵。详情请参见图的表示法。 39 | * 你可以假定输入的先决条件中没有重复的边。 40 | 41 | 42 | ## 2. 最小高度树 43 | 44 | 对于一个具有树特征的无向图,我们可选择任何一个节点作为根。图因此可以成为树,在所有可能的树中,具有最小高度的树被称为最小高度树。给出这样的一个图,写出一个函数找到所有的最小高度树并返回他们的根节点。 45 | 46 | 格式: 47 | * 该图包含 `n` 个节点,标记为 `0` 到 `n - 1`。给定数字 `n` 和一个无向边 `edges` 列表(每一个边都是一对标签)。 48 | * 你可以假设没有重复的边会出现在 `edges` 中。由于所有的边都是无向边, `[0, 1]` 和 `[1, 0]` 是相同的,因此不会同时出现在 `edges` 里。 49 | 50 | 示例 1: 51 | ``` 52 | 输入: 53 | n = 4, 54 | edges = [[1, 0], [1, 2], [1, 3]] 55 | 56 | 0 57 | | 58 | 1 59 | / \ 60 | 2 3 61 | 62 | 输出: 63 | [1] 64 | ``` 65 | 66 | 示例 2: 67 | ``` 68 | 输入: 69 | n = 6, 70 | edges = [[0, 3], [1, 3], [2, 3], [4, 3], [5, 4]] 71 | 72 | 0 1 2 73 | \ | / 74 | 3 75 | | 76 | 4 77 | | 78 | 5 79 | 80 | 输出: 81 | [3, 4] 82 | ``` 83 | 84 | -------------------------------------------------------------------------------- /2_datastructure_algorithm/README.md: -------------------------------------------------------------------------------- 1 | # 算法、数据结构学习 2 | 3 | ## 1. 基本要求 4 | 学习链表、二叉树、红黑树、图的遍历;查找,排序;动态规划、贪心算法等知识,并编写练习题。 5 | 6 | ## 2. 学习方法和资料 7 | 可以选择 《算法导论》来学习,也可以通过数据结构来学习。 8 | * 根据自己的基础,把重要的内容学一下,并尝试将每一个算法都自己实现一下 (大约4-8周) 9 | * 实现过程需要思考,算法的本质是什么,如何将算法转化成循环、判断 10 | * 如何实现算法,如何测试代码,如何构建输入数据 11 | * 可以参考一些教程,加快学习速度,例如: 12 | - [麻省理工学院公开课:算法导论](http://open.163.com/special/opencourse/algorithms.html) 13 | - [你是如何坚持读完《算法导论》这本书的?](https://www.zhihu.com/question/27744730) 14 | - [数据结构与算法入门](https://www.dotcpp.com/course/ds/) 15 | 16 | 17 | ## 3. 综合练习 18 | 在学习过程可以将每一章节的练习题目做一下,每一个知识点通过练习加强理解和认识。在学习完成之后,需要完成综合练习题,通过编写完整的数据读入、预处理、算法、输出等部分,此外通过编写代码、Debug提高分析问题、综合解决问题的能力。 19 | 20 | 综合练习题目分为下面几个部分: 21 | * [string](0_string/README.md) 22 | * [array and sort](1_array_sort/README.md) 23 | * [list](2_list/README.md) 24 | * [tree](3_tree/README.md) 25 | * [graph](4_graph/README.md) 26 | * [algorithm](5_algorithm/README.md) 27 | -------------------------------------------------------------------------------- /3_code_practice/README.md: -------------------------------------------------------------------------------- 1 | # 算法练习题 2 | 3 | 为了巩固编程、算法,需要做一些练习题,最少在50道以上。可以根据自己的能力,选择如下的练习来完成 4 | * [初级算法 - 帮助入门](https://leetcode-cn.com/explore/interview/card/top-interview-questions-easy/) 5 | * [中级算法 - 巩固训练](https://leetcode-cn.com/explore/interview/card/top-interview-questions-medium/) 6 | * [高级算法 - 提升进阶](https://leetcode-cn.com/explore/interview/card/top-interview-questions-hard/) 7 | 8 | 将编写的程序按照类别等存放在这个文件夹。 9 | 10 | 11 | 12 | ## 1. 练习的建议 13 | 14 | 打开 LeetCode 网站,按照题目类型数量分类,最多的几个题型有数组、动态规划、数学、字符串、树、哈希表、深度优先搜索、二分查找、贪心算法、广度优先搜索、双指针等等。**这部分是重点练习的对象。** 15 | 16 | * 第一个大分类是算法,可以先从最简单的贪心算法开始,然后逐渐进阶到二分查找、排序算法和搜索算法,最后是难度比较高的动态规划和分治算法。 17 | 18 | * 第二个大分类是数学,包括偏向纯数学的数学问题,和偏向计算机知识的位运算问题。这类问题通常用来测试你是否聪敏,在实际工作中并不常用,建议可以优先把精力放在其它大类上。 19 | * 第三个大分类是数据结构,包括 C++ STL 内包含的常见数据结构、字符串处理、链表、树和图。其中,链表、树、和图都是用指针表示的数据结构,且前者是后者的子集。**这部分是重点练习的对象。** 20 | 21 | ![overview](images/overview.png) 22 | 23 | ## 2. 参考资料 24 | 25 | * [LeetCode 101](https://github.com/changgyhub/leetcode_101) : 如果遇到实在不会的,可以参考里面的解题思路 26 | * [LeetCode Note](https://github.com/changgyhub/notes/tree/master/leetcode) 27 | 28 | -------------------------------------------------------------------------------- /3_code_practice/images/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/3_code_practice/images/overview.png -------------------------------------------------------------------------------- /4_projects/images/dynamic_pathplanning.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/images/dynamic_pathplanning.gif -------------------------------------------------------------------------------- /4_projects/images/formation_1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/images/formation_1.gif -------------------------------------------------------------------------------- /4_projects/images/inverted_pendulum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/images/inverted_pendulum.png -------------------------------------------------------------------------------- /4_projects/images/inverted_pendulum_ori.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/images/inverted_pendulum_ori.png -------------------------------------------------------------------------------- /4_projects/images/lane_tracking.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/images/lane_tracking.jpeg -------------------------------------------------------------------------------- /4_projects/images/lane_tracking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/images/lane_tracking.png -------------------------------------------------------------------------------- /4_projects/images/markerland.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/images/markerland.gif -------------------------------------------------------------------------------- /4_projects/images/shudu.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/images/shudu.jpeg -------------------------------------------------------------------------------- /4_projects/images/tetris.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/images/tetris.png -------------------------------------------------------------------------------- /4_projects/images/tetris_ori.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/images/tetris_ori.png -------------------------------------------------------------------------------- /4_projects/images/uav_autolanding.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/images/uav_autolanding.png -------------------------------------------------------------------------------- /4_projects/images/uav_circle.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/images/uav_circle.jpeg -------------------------------------------------------------------------------- /4_projects/images/uav_flightformation-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/images/uav_flightformation-0.png -------------------------------------------------------------------------------- /4_projects/images/uav_flightformation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/images/uav_flightformation.png -------------------------------------------------------------------------------- /4_projects/images/wuziqi_cvc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/images/wuziqi_cvc.gif -------------------------------------------------------------------------------- /4_projects/qt_demos/1_simple_draw/README.md: -------------------------------------------------------------------------------- 1 | # Simple draw of Qt 2 | 3 | 这个程序演示一个最简单的Qt画图程序,能够在这个程序的基础上编写自己所需要的画图程序。 4 | 5 | ## 1. 编译 6 | 这个程序运行在Qt4环境下,如果没有安装Qt4,可以通过以下命令安装Qt4。强烈建议在Linux编译这个程序,Windows下,需要自己去找资料如何安装Qt库。 7 | ``` 8 | sudo apt-get install libqt4-dev libqt4-opengl-dev 9 | ``` 10 | 11 | 12 | 编译过程: 13 | ``` 14 | qmake-qt4 simple_draw.pro 15 | make 16 | ``` 17 | 18 | ## 2. 使用方法 19 | 20 | 编译后如果不出现意外的话,会有一个可程序程序`simple_draw`,运行的方法为: 21 | ``` 22 | ./simple_draw 23 | ``` 24 | 25 | 程序运行界面: 26 | ![simple_draw screenshot](images/simple_draw.png) 27 | 28 | 按键: 29 | ``` 30 | o - 随机画1000个彩色的矩形, 31 | 绘图函数在:mainwindow.cpp: line 44 32 | void MainWindow::keyPressEvent(QKeyEvent *event) 33 | 34 | c - 清空画板,使用给定的颜色 35 | 绘图函数在:mainwindow.cpp: line 63 36 | void MainWindow::keyPressEvent(QKeyEvent *event) 37 | 38 | q - 退出程序 39 | 代码在:mainwindow.cpp: line 69 40 | ``` 41 | 42 | ## 3. 程序的基本结构 43 | 这个程序没有直接用`MainWindow::paintEvent`来完成画图,而是创建了一个后台的图像。所有的绘图操作先画在这个后台图像,然后等窗口重绘的时候,将后台图像绘制到窗口上。 44 | 45 | 主要的流程: 46 | 1. `MainWindow::MainWindow(QWidget *parent)` 完成窗口的初始化,创建后台画图的图像 47 | 2. `void MainWindow::keyPressEvent(QKeyEvent *event)` 接收键盘的按键,并完成对应的操作 48 | 3. `void MainWindow::paintEvent(QPaintEvent * /* event */)` 将后台图像绘制到窗口上 49 | 50 | -------------------------------------------------------------------------------- /4_projects/qt_demos/1_simple_draw/images/simple_draw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/qt_demos/1_simple_draw/images/simple_draw.png -------------------------------------------------------------------------------- /4_projects/qt_demos/1_simple_draw/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "mainwindow.h" 5 | 6 | 7 | //////////////////////////////////////////////////////////////////////////////// 8 | //////////////////////////////////////////////////////////////////////////////// 9 | 10 | int main(int argc, char *argv[]) 11 | { 12 | QApplication app(argc, argv); 13 | 14 | 15 | // create main window 16 | MainWindow win; 17 | win.setWindowTitle("Simpel Draw"); 18 | //win.setFixedSize(800, 600); 19 | win.show(); 20 | 21 | // begin Qt GUI loop 22 | app.exec(); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /4_projects/qt_demos/1_simple_draw/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef __MAINWINDOW_H__ 2 | #define __MAINWINDOW_H__ 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | //////////////////////////////////////////////////////////////////////////////// 12 | //////////////////////////////////////////////////////////////////////////////// 13 | 14 | class MainWindow : public QWidget 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | MainWindow(QWidget *parent = 0); 20 | 21 | protected: 22 | void paintEvent(QPaintEvent *event); 23 | void keyPressEvent(QKeyEvent *event); 24 | void mousePressEvent(QMouseEvent *event); 25 | void mouseMoveEvent(QMouseEvent *event); 26 | void timerEvent(QTimerEvent *event); 27 | 28 | private: 29 | QImage *m_img; 30 | }; 31 | 32 | 33 | #endif // end of __MAINWINDOW_H__ 34 | 35 | -------------------------------------------------------------------------------- /4_projects/qt_demos/1_simple_draw/simple_draw.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | QT += gui widgets 3 | TARGET = simple_draw 4 | 5 | SOURCES += \ 6 | ./mainwindow.cpp \ 7 | ./main.cpp 8 | 9 | HEADERS += \ 10 | ./mainwindow.h 11 | 12 | 13 | -------------------------------------------------------------------------------- /4_projects/qt_demos/2_draw_map/draw_map.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ****************************************************************************/ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "map_viewer.h" 9 | 10 | int main(int argc, char **argv) 11 | { 12 | QApplication app(argc, argv); 13 | 14 | // set random seed 15 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); 16 | 17 | MapViewer *widget = new MapViewer; 18 | 19 | QMainWindow mainWindow; 20 | mainWindow.setCentralWidget(widget); 21 | mainWindow.show(); 22 | 23 | return app.exec(); 24 | } 25 | -------------------------------------------------------------------------------- /4_projects/qt_demos/2_draw_map/draw_map.pro: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # Automatically generated by qmake (3.0) Wed Mar 18 17:00:32 2020 3 | ###################################################################### 4 | 5 | TEMPLATE = app 6 | TARGET = draw_map 7 | QT += gui widgets 8 | 9 | INCLUDEPATH += . 10 | 11 | # Input 12 | HEADERS += map_viewer.h 13 | SOURCES += draw_map.cpp map_viewer.cpp 14 | -------------------------------------------------------------------------------- /4_projects/qt_demos/README.md: -------------------------------------------------------------------------------- 1 | # Qt demos 2 | 3 | 这个目录包含了最基本的Qt用法的例子,通过修改例子程序来实现自己想要实现的功能。 4 | 5 | ## 安装与编译 6 | 这个程序运行在Qt4环境下,如果没有安装Qt4,可以通过以下命令安装Qt4。强烈建议在Linux编译这个程序,Windows下,需要自己去找资料如何安装Qt库。 7 | 8 | Linux的学习教程: [Linux教程](../../6_tools/linux/README.md) 9 | 10 | 安装Qt环境 11 | ``` 12 | sudo apt-get install libqt4-dev libqt4-opengl-dev qtcreator 13 | ``` 14 | 15 | 打开项目文件,编辑等: 16 | ``` 17 | qtcreator simple_draw.pro 18 | ``` 19 | 20 | 对于例子1: `1_simple_draw`,编译过程如下: 21 | ``` 22 | qmake-qt4 simple_draw.pro 23 | make 24 | ``` 25 | 26 | ## 其他例子程序 27 | 28 | * [DynamicPathPlanning](https://gitee.com/pi-lab/DynamicPathPlanning) - Demo of dynamic path planning 29 | 30 | * [FastSLAM](https://gitee.com/pi-lab/fastslam) - FastSLAM with GUI 31 | * [SimpGCS](https://gitee.com/pi-lab/SimpGCS) - Simple Ground Control Station 32 | 33 | - [PI-SLAM](https://gitee.com/pi-lab/pi-slam) - Modularized SLAM System by PI-LAB -------------------------------------------------------------------------------- /4_projects/sfml_demos/1_Tetris/README.md: -------------------------------------------------------------------------------- 1 | # SFML demo - Tetris 2 | 3 | ## Install dependencies on Ubuntu: 4 | ``` 5 | sudo apt-get install libsfml-dev 6 | ``` 7 | 8 | 9 | ## Basic usage of Linux 10 | Linux的基本用法可以参考 [Linux教程](../../../6_tools/linux/README.md) 11 | 12 | 13 | ## Compile the code: 14 | ``` 15 | g++ main.cpp -lsfml-graphics -lsfml-window -lsfml-system 16 | ``` 17 | 18 | 19 | ## Key 20 | ``` 21 | UP - change blocks 22 | DOWN - fast fall down 23 | LEFT - move block to left 24 | RIGHT - move block to right 25 | ``` 26 | 27 | 28 | ## Screenshot 29 | ![screen-shot](images/screen_shot.png) 30 | -------------------------------------------------------------------------------- /4_projects/sfml_demos/1_Tetris/images/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/sfml_demos/1_Tetris/images/background.png -------------------------------------------------------------------------------- /4_projects/sfml_demos/1_Tetris/images/frame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/sfml_demos/1_Tetris/images/frame.png -------------------------------------------------------------------------------- /4_projects/sfml_demos/1_Tetris/images/screen_shot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/sfml_demos/1_Tetris/images/screen_shot.png -------------------------------------------------------------------------------- /4_projects/sfml_demos/1_Tetris/images/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/sfml_demos/1_Tetris/images/tiles.png -------------------------------------------------------------------------------- /4_projects/sfml_demos/2_Snake/README.md: -------------------------------------------------------------------------------- 1 | # SFML demo - Snake 2 | 3 | ## Install dependencies on Ubuntu: 4 | ``` 5 | sudo apt-get install libsfml-dev 6 | ``` 7 | 8 | 9 | ## Basic usage of Linux 10 | Linux的基本用法可以参考 [Linux教程](../../../6_tools/linux/README.md) 11 | 12 | 13 | ## Compile the code: 14 | ``` 15 | g++ main.cpp -lsfml-graphics -lsfml-window -lsfml-system 16 | ``` 17 | 18 | 19 | ## Key 20 | ``` 21 | UP - change direction of snake to up 22 | DOWN - change direction of snake to down 23 | LEFT - change direction of snake to left 24 | RIGHT - change direction of snake to right 25 | ``` 26 | 27 | 28 | ## Screenshot 29 | ![screen-shot](images/screen_shot.png) 30 | -------------------------------------------------------------------------------- /4_projects/sfml_demos/2_Snake/images/green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/sfml_demos/2_Snake/images/green.png -------------------------------------------------------------------------------- /4_projects/sfml_demos/2_Snake/images/red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/sfml_demos/2_Snake/images/red.png -------------------------------------------------------------------------------- /4_projects/sfml_demos/2_Snake/images/screen_shot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/sfml_demos/2_Snake/images/screen_shot.png -------------------------------------------------------------------------------- /4_projects/sfml_demos/2_Snake/images/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/sfml_demos/2_Snake/images/white.png -------------------------------------------------------------------------------- /4_projects/sfml_demos/3_Chess/images/board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/sfml_demos/3_Chess/images/board.png -------------------------------------------------------------------------------- /4_projects/sfml_demos/3_Chess/images/board0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/sfml_demos/3_Chess/images/board0.png -------------------------------------------------------------------------------- /4_projects/sfml_demos/3_Chess/images/figures.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/sfml_demos/3_Chess/images/figures.png -------------------------------------------------------------------------------- /4_projects/sfml_demos/3_Chess/stockfish: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/sfml_demos/3_Chess/stockfish -------------------------------------------------------------------------------- /4_projects/sfml_demos/3_Chess/stockfish.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/4_projects/sfml_demos/3_Chess/stockfish.exe -------------------------------------------------------------------------------- /4_projects/sfml_demos/README.md: -------------------------------------------------------------------------------- 1 | # SFML demos 2 | 3 | ## 简介 4 | 5 | SFML是一个简单易用的GUI图形库,能够方便地编写具有绘图、键盘相应功能的程序。比较快速的学习方法是,通过示例程序来学习如何使用这个图形库。主要的学习步骤是: 6 | 7 | 1. 由于Linux下编译这个程序比较方便,因此强烈建议先简单的学习一下如何使用Linux,具体的教程可以参考: [Linux教程](../../6_tools/linux/README.md) 8 | 2. 编译、运行例子程序。建立直觉的认识,看看例子代码,了解基本的程序流程、函数 9 | 3. 构思自己所写的程序和例子程序的差异,想想如何在例子程序的基础上修改。如果遇到不会的地方,可以尝试查阅资料: [SFML学习资料](https://gitee.com/pi-lab/resources/tree/master/books/sfml/SFML-2.5.1_doc) 10 | 4. 不要想一次把程序写完美,可以逐步完善,每次添加一个功能,直到主要的功能完成。大体完成之后,再查资料、或者讨论,将程序最终完善。 11 | 12 | 13 | 14 | ## Demos 15 | 16 | Tetris: 17 | 18 | ![screen-shot](1_Tetris/images/screen_shot.png) 19 | 20 | 21 | 22 | Snake: 23 | 24 | ![screen-shot](2_Snake/images/screen_shot.png) 25 | 26 | ## Install dependencies on Ubuntu: 27 | 28 | ``` 29 | sudo apt-get install libsfml-dev 30 | ``` 31 | 32 | ## Compile the code: 33 | 34 | ``` 35 | g++ main.cpp -lsfml-graphics -lsfml-window -lsfml-system 36 | ``` 37 | -------------------------------------------------------------------------------- /5_advanced/3_Library/simple_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.5) 3 | 4 | PROJECT (simple_lib) 5 | 6 | LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) 7 | include(cmake/PICMake.cmake) 8 | 9 | ADD_SUBDIRECTORY(utils) 10 | 11 | 12 | INCLUDE_DIRECTORIES(utils) 13 | 14 | pi_add_target(test_utils BIN test_utils REQUIRED Utils) 15 | 16 | pi_report_targets() 17 | 18 | -------------------------------------------------------------------------------- /5_advanced/3_Library/simple_lib/cmake/FindUtils.cmake: -------------------------------------------------------------------------------- 1 | set(UTILS_FOUND 1) 2 | 3 | set(UTILS_LIBRARIES utils) 4 | 5 | -------------------------------------------------------------------------------- /5_advanced/3_Library/simple_lib/test_utils/test_utils.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "utils.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | // call lib's function 8 | std::string s = " Hello World! "; 9 | std::cout << "trim(s) = " << trim(s) << std::endl; 10 | 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /5_advanced/3_Library/simple_lib/utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.6) 2 | 3 | project(demo_libutils) 4 | 5 | 6 | pi_add_target(utils STATIC utils.cpp) 7 | 8 | pi_report_target() 9 | 10 | 11 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | Release/ 3 | *.sdf 4 | *.opensdf 5 | *.suo 6 | .idea 7 | build/ 8 | *~ 9 | .DS_Store 10 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/AbstractFactoryPattern/AbstractFactoryPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | // Product 5 | 6 | class AbstractProduct { 7 | public: 8 | virtual ~AbstractProduct() { } 9 | virtual void Operation() = 0; 10 | }; 11 | 12 | class ProductA :public AbstractProduct { 13 | public: 14 | void Operation() { 15 | cout << "ProductA Operation" << endl; 16 | } 17 | }; 18 | 19 | class ProductB :public AbstractProduct { 20 | public: 21 | void Operation() { 22 | cout << "ProductB Operation" << endl; 23 | } 24 | }; 25 | 26 | // Factory 27 | 28 | class AbstractFactory { 29 | public: 30 | virtual ~AbstractFactory() { } 31 | virtual AbstractProduct* CreateProductA() = 0; 32 | virtual AbstractProduct* CreateProductB() = 0; 33 | }; 34 | 35 | class ConcreteFactory :public AbstractFactory { 36 | public: 37 | AbstractProduct* CreateProductA() { 38 | return new ProductA(); 39 | } 40 | 41 | AbstractProduct* CreateProductB() { 42 | return new ProductB(); 43 | } 44 | }; 45 | 46 | int main() { 47 | AbstractFactory *factory = new ConcreteFactory(); 48 | AbstractProduct* productA = factory->CreateProductA(); 49 | AbstractProduct* productB = factory->CreateProductB(); 50 | productA->Operation(); 51 | productB->Operation(); 52 | 53 | delete factory; 54 | delete productA; 55 | delete productB; 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/AbstractFactoryPattern/AbstractFactoryPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/AdapterPattern/AdapterPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Target { 5 | public: 6 | virtual void Request() { 7 | cout << "Target::Request..." << endl; 8 | } 9 | virtual ~Target() { } 10 | }; 11 | 12 | class Adaptee { 13 | public: 14 | void SpecificRequest() { 15 | cout << "Adaptee::SpecificRequest..." << endl; 16 | } 17 | }; 18 | 19 | class Adapter :public Target, private Adaptee { 20 | public: 21 | Adapter(Adaptee* ade) { 22 | _ade = ade; 23 | } 24 | void Request() { 25 | _ade->SpecificRequest(); 26 | } 27 | private: 28 | Adaptee *_ade; 29 | }; 30 | 31 | int main() { 32 | Adaptee *adaptee = new Adaptee(); 33 | Target *adapter = new Adapter(adaptee); 34 | 35 | adapter->Request(); 36 | 37 | delete adapter; 38 | delete adaptee; 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/AdapterPattern/AdapterPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/BridgePattern/BridgePattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | // Abstraction 5 | 6 | class Abstraction { 7 | public: 8 | virtual void Operation() = 0; 9 | virtual ~Abstraction() { } 10 | protected: 11 | Abstraction() { } 12 | }; 13 | 14 | // AbstractionImp 15 | 16 | class AbstractionImp :public Abstraction { 17 | public: 18 | virtual void Operation() = 0; 19 | virtual ~AbstractionImp() { } 20 | protected: 21 | AbstractionImp() { } 22 | }; 23 | 24 | class ConcreteAbstractionImp :public AbstractionImp { 25 | public: 26 | void Operation() { 27 | cout << "ConcreteAbstractionImp Operation..." << endl; 28 | } 29 | }; 30 | 31 | class RefinedAbstraction :public Abstraction { 32 | public: 33 | RefinedAbstraction(AbstractionImp *imp) { 34 | _imp = imp; 35 | } 36 | void Operation() { 37 | _imp->Operation(); 38 | } 39 | private: 40 | AbstractionImp *_imp; 41 | }; 42 | 43 | 44 | 45 | 46 | 47 | int main() { 48 | 49 | AbstractionImp *imp = new ConcreteAbstractionImp(); 50 | 51 | Abstraction *abs = new RefinedAbstraction(imp); 52 | 53 | abs->Operation(); 54 | 55 | delete imp; 56 | delete abs; 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/BridgePattern/BridgePattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/BuilderPattern/BuilderPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | // Product 5 | 6 | class Product { 7 | public: 8 | Product() { 9 | cout << "Product..." << endl; 10 | } 11 | }; 12 | 13 | // Builder 14 | 15 | class Builder { 16 | public: 17 | virtual void BuildPartA() = 0; 18 | virtual void BuildPartB() = 0; 19 | virtual void BuildPartC() = 0; 20 | virtual Product* GetProduct() = 0; 21 | virtual ~Builder() { } 22 | }; 23 | 24 | class ConcreteBuilder :public Builder { 25 | public: 26 | void BuildPartA() { 27 | cout << "BuildPartA..." << endl; 28 | } 29 | 30 | void BuildPartB() { 31 | cout << "BuildPartB..." << endl; 32 | } 33 | 34 | void BuildPartC() { 35 | cout << "BuildPartC..." << endl; 36 | } 37 | 38 | Product* GetProduct() { 39 | return new Product(); 40 | } 41 | }; 42 | 43 | // Director 44 | 45 | class Director { 46 | public: 47 | Director(Builder* pBuilder) { 48 | _builer = pBuilder; 49 | } 50 | 51 | void Construct() { 52 | _builer->BuildPartA(); 53 | _builer->BuildPartB(); 54 | _builer->BuildPartC(); 55 | } 56 | 57 | private: 58 | Builder *_builer; 59 | }; 60 | 61 | 62 | int main() { 63 | auto builder = new ConcreteBuilder(); 64 | auto director = new Director(builder); 65 | director->Construct(); 66 | Product* product = builder->GetProduct(); 67 | 68 | delete product; 69 | delete builder; 70 | delete director; 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/BuilderPattern/BuilderPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | project(DesignPattern) 3 | 4 | set(CMAKE_CXX_STANDARD 11) 5 | 6 | 7 | set(PATTERNS 8 | AbstractFactoryPattern 9 | AdapterPattern 10 | BridgePattern 11 | BuilderPattern 12 | ChainOfResponsibilityPattern 13 | CommandPattern 14 | CompositePattern 15 | DecoratorPattern 16 | FacadePattern 17 | FactoryPattern 18 | FlyweightPattern 19 | InterpreterPattern 20 | IteratorPattern 21 | MediatorPattern 22 | MementoPattern 23 | ObserverPattern 24 | PrototypePattern 25 | ProxyPattern 26 | SingletonPattern 27 | StatePattern 28 | StrategyPattern 29 | TemplatePattern 30 | VisitorPattern) 31 | 32 | macro(add_pattern PATTERN) 33 | include_directories(${PATTERN}) 34 | file(GLOB_RECURSE PATTERN_FILES "${PATTERN}/*.cpp") 35 | add_executable(${PATTERN} ${PATTERN_FILES}) 36 | endmacro(add_pattern) 37 | 38 | foreach(PATTERN IN LISTS PATTERNS) 39 | message(STATUS "Found Pattern: ${PATTERN}") 40 | add_pattern(${PATTERN}) 41 | endforeach(PATTERN) 42 | 43 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/ChainOfResponsibilityPattern/ChainOfResponsibilityPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Handle { 5 | public: 6 | virtual ~Handle() { } 7 | 8 | virtual void HandleRequest() = 0; 9 | 10 | void SetSuccessor(Handle *succ) { 11 | _succ = succ; 12 | } 13 | 14 | Handle* GetSuccessor()const { 15 | return _succ; 16 | } 17 | 18 | protected: 19 | Handle() { _succ = nullptr; } 20 | 21 | Handle(Handle* succ) { 22 | _succ = succ; 23 | } 24 | private: 25 | Handle* _succ; 26 | }; 27 | 28 | class ConcreteHandleA :public Handle { 29 | public: 30 | ConcreteHandleA() { } 31 | 32 | ConcreteHandleA(Handle* succ) 33 | :Handle(succ) { 34 | } 35 | 36 | void HandleRequest() { 37 | if (this->GetSuccessor() != 0) { 38 | cout << "ConcreteHandleA--Successor" << endl; 39 | GetSuccessor()->HandleRequest(); 40 | } 41 | else { 42 | cout << "ConcreteHandleA::HandleRequest" << endl; 43 | } 44 | } 45 | }; 46 | 47 | class ConcreteHandleB :public Handle { 48 | public: 49 | ConcreteHandleB() { } 50 | 51 | ConcreteHandleB(Handle* succ) 52 | :Handle(succ) { 53 | } 54 | 55 | void HandleRequest() { 56 | if (this->GetSuccessor() != 0) { 57 | cout << "ConcreteHandleB--Successor" << endl; 58 | GetSuccessor()->HandleRequest(); 59 | } 60 | else { 61 | cout << "ConcreteHandleB::HandleRequest" << endl; 62 | } 63 | } 64 | }; 65 | 66 | int main() { 67 | Handle *h1 = new ConcreteHandleA(); 68 | Handle *h2 = new ConcreteHandleB(h1);// or h1->SetSuccessor(h2); 69 | h2->HandleRequest(); 70 | 71 | delete h1; 72 | delete h2; 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/ChainOfResponsibilityPattern/ChainOfResponsibilityPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/CommandPattern/CommandPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Reciever { 5 | public: 6 | void Action() { 7 | cout << "Reciever::Action..." << endl; 8 | } 9 | }; 10 | 11 | class Command { 12 | public: 13 | virtual ~Command() { } 14 | virtual void Excute() = 0; 15 | }; 16 | 17 | class ConcreteCommand :public Command { 18 | public: 19 | ConcreteCommand(Reciever *rev) { 20 | _rev = rev; 21 | } 22 | 23 | void Excute() { 24 | _rev->Action(); 25 | } 26 | private: 27 | Reciever *_rev; 28 | }; 29 | 30 | class Invoker { 31 | public: 32 | Invoker(Command* cmd) { 33 | _cmd = cmd; 34 | } 35 | void Invoke() { 36 | _cmd->Excute(); 37 | } 38 | 39 | private: 40 | Command *_cmd; 41 | }; 42 | 43 | int main() { 44 | Reciever *rev = new Reciever(); 45 | Command* cmd = new ConcreteCommand(rev); 46 | Invoker *inv = new Invoker(cmd); 47 | inv->Invoke(); 48 | 49 | delete rev; 50 | delete cmd; 51 | delete inv; 52 | 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/CommandPattern/CommandPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/CompositePattern/CompositePattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | class Component { 6 | public: 7 | virtual void Operation() { } 8 | 9 | virtual void Add(const Component& com) { } 10 | 11 | virtual void Remove(const Component& com) { } 12 | 13 | virtual Component* GetChild(int index) { 14 | return 0; 15 | } 16 | 17 | virtual ~Component() { } 18 | }; 19 | 20 | class Composite :public Component { 21 | public: 22 | void Add(Component* com) { 23 | _coms.push_back(com); 24 | } 25 | 26 | void Operation() { 27 | for (auto com : _coms) 28 | com->Operation(); 29 | } 30 | 31 | void Remove(Component* com) { 32 | //_coms.erase(&com); 33 | } 34 | 35 | Component* GetChild(int index) { 36 | return _coms[index]; 37 | } 38 | 39 | private: 40 | std::vector _coms; 41 | }; 42 | 43 | class Leaf :public Component { 44 | public: 45 | void Operation() { 46 | cout << "Leaf::Operation..." << endl; 47 | } 48 | }; 49 | 50 | 51 | int main() { 52 | Leaf *leaf = new Leaf(); 53 | leaf->Operation(); 54 | Composite *com = new Composite(); 55 | com->Add(leaf); 56 | com->Operation(); 57 | Component *leaf_ = com->GetChild(0); 58 | leaf_->Operation(); 59 | 60 | delete leaf; 61 | delete com; 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/CompositePattern/CompositePattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/DecoratorPattern/DecoratorPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Component { 5 | public: 6 | virtual void Operation() = 0; 7 | virtual ~Component() { } 8 | }; 9 | 10 | class ConcreteComponent :public Component { 11 | public: 12 | void Operation() { 13 | cout << "ConcreteComponent::Operation..." << endl; 14 | } 15 | }; 16 | 17 | class Decorator { 18 | public: 19 | virtual void Operation() = 0; 20 | virtual void AddBehavior() = 0; 21 | virtual ~Decorator() { } 22 | }; 23 | 24 | class ConcreteDecorator :public Decorator { 25 | public: 26 | ConcreteDecorator(Component *com) { 27 | _com = com; 28 | } 29 | 30 | void AddBehavior() { 31 | cout << "ConcreteDecorator::AddBehavior..." << endl; 32 | } 33 | 34 | void Operation() { 35 | cout << "ConcreteDecorator::Operation..." << endl; 36 | AddBehavior(); 37 | _com->Operation(); 38 | } 39 | private: 40 | Component *_com; 41 | }; 42 | 43 | int main() { 44 | Component *con = new ConcreteComponent(); 45 | Decorator *dec = new ConcreteDecorator(con); 46 | dec->Operation(); 47 | 48 | delete con; 49 | delete dec; 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/DecoratorPattern/DecoratorPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/FacadePattern/FacadePattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class SubSystem1 { 5 | public: 6 | void Operation() { 7 | cout << "SubSystem1 operation..." << endl; 8 | } 9 | }; 10 | 11 | class SubSystem2 { 12 | public: 13 | void Operation() { 14 | cout << "SubSystem2 operation..." << endl; 15 | } 16 | }; 17 | 18 | class Facade { 19 | public: 20 | Facade() { 21 | _sub1 = new SubSystem1(); 22 | _sub2 = new SubSystem2(); 23 | } 24 | 25 | ~Facade() { 26 | delete _sub1; 27 | delete _sub2; 28 | } 29 | 30 | void OperationWrapper() { 31 | _sub1->Operation(); 32 | _sub2->Operation(); 33 | } 34 | private: 35 | SubSystem1 *_sub1; 36 | SubSystem2 *_sub2; 37 | }; 38 | 39 | 40 | int main() { 41 | Facade *facade = new Facade(); 42 | facade->OperationWrapper(); 43 | 44 | delete facade; 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/FacadePattern/FacadePattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/FactoryPattern/FactoryPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // Product 4 | 5 | class Product { 6 | public: 7 | virtual ~Product() { } 8 | virtual void say() = 0; 9 | }; 10 | 11 | class ConcreteProduct :public Product { 12 | public: 13 | ConcreteProduct() { 14 | std::cout << "ConcreteProduct..." << std::endl; 15 | } 16 | void say() { 17 | std::cout << "ConcreteProduct Say..." << std::endl; 18 | } 19 | ~ConcreteProduct() { } 20 | }; 21 | 22 | // Factory 23 | 24 | class Factory { 25 | public: 26 | virtual Product* CreateProduct() = 0; 27 | virtual ~Factory() { } 28 | protected: 29 | Factory() { } 30 | }; 31 | 32 | class ConcreteFactory :public Factory { 33 | public: 34 | ConcreteFactory() { 35 | std::cout << "ConcreteFactory..." << std::endl; 36 | } 37 | 38 | ~ConcreteFactory() { 39 | 40 | } 41 | 42 | Product* CreateProduct() { 43 | return new ConcreteProduct(); 44 | } 45 | 46 | }; 47 | 48 | // Test 49 | 50 | int main() { 51 | Factory *factory = new ConcreteFactory(); 52 | Product *product = factory->CreateProduct(); 53 | product->say(); 54 | 55 | delete factory; 56 | delete product; 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/FactoryPattern/FactoryPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/FlyweightPattern/FlyweightPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | class Flyweight { 8 | public: 9 | Flyweight(string state):_state(state) { 10 | 11 | } 12 | 13 | virtual void Operation(const string&state) { } 14 | 15 | string GetState()const { return _state; } 16 | 17 | virtual ~Flyweight() { } 18 | private: 19 | string _state; 20 | }; 21 | 22 | class ConcreteFlyweight :public Flyweight { 23 | public: 24 | ConcreteFlyweight(string state) 25 | :Flyweight(state) { 26 | cout << "ConcreteFlyweight Build..." << state << endl; 27 | } 28 | 29 | void Operation(const string& state) { 30 | cout << "ConcreteFlyweight " << GetState() << " \\ " << state << endl; 31 | } 32 | }; 33 | 34 | class FlyweightFactory { 35 | public: 36 | Flyweight *GetFlyweight(std::string key) { 37 | for (auto fly : _flys) { 38 | if (fly->GetState() == key) { 39 | cout << "already created by users..." << endl; 40 | return fly; 41 | } 42 | } 43 | Flyweight *fn = new ConcreteFlyweight(key); 44 | _flys.push_back(fn); 45 | return fn; 46 | } 47 | private: 48 | std::vector _flys; 49 | }; 50 | 51 | int main() { 52 | FlyweightFactory *fc = new FlyweightFactory(); 53 | Flyweight *fw1 = fc->GetFlyweight("hello"); 54 | Flyweight *fw2 = fc->GetFlyweight("world"); 55 | Flyweight *fw3 = fc->GetFlyweight("hello"); 56 | 57 | delete fw1; 58 | delete fw2; 59 | //delete fw3; 60 | delete fc; 61 | 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/FlyweightPattern/FlyweightPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/InterpreterPattern/InterpreterPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | class Context { }; 6 | 7 | class Expression { 8 | public: 9 | virtual ~Expression() { } 10 | virtual void Interpret(const Context& c) = 0; 11 | }; 12 | 13 | class TerminalExpression :public Expression { 14 | public: 15 | TerminalExpression(const string& statement) { 16 | _statement = statement; 17 | } 18 | 19 | void Interpret(const Context& c) { 20 | cout << this->_statement << " -- TerminalExpression" << endl; 21 | } 22 | 23 | private: 24 | string _statement; 25 | }; 26 | 27 | class NonterminalExpression :public Expression { 28 | public: 29 | NonterminalExpression(Expression* expression, int times) { 30 | _expression = expression; 31 | _times = times; 32 | } 33 | 34 | void Interpret(const Context& c) { 35 | for (int i = 0; i < _times; i++) { 36 | _expression->Interpret(c); 37 | } 38 | } 39 | 40 | private: 41 | Expression *_expression; 42 | int _times; 43 | }; 44 | 45 | int main() { 46 | Context *c = new Context(); 47 | Expression *tp = new TerminalExpression("echo"); 48 | Expression *ntp = new NonterminalExpression(tp, 4); 49 | ntp->Interpret(*c); 50 | 51 | delete ntp; 52 | delete tp; 53 | delete c; 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/InterpreterPattern/InterpreterPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/IteratorPattern/Aggregate.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #include "Aggregate.h" 5 | #include "Iterator.h" 6 | 7 | Aggregate::Aggregate() { 8 | } 9 | 10 | Aggregate::~Aggregate() { 11 | } 12 | 13 | ConcreteAggreaget::ConcreteAggreaget() { 14 | for (int i = 0; i < SIZE; i++) { 15 | _objs[i] = i; 16 | } 17 | } 18 | 19 | //Iterator* ConcreteAggreaget::CreateIterator() { 20 | // return new ConcreteIterator(this); 21 | //} 22 | 23 | Object ConcreteAggreaget::GetItem(int idx) { 24 | if (idx < this->GetSize()) { 25 | return _objs[idx]; 26 | } 27 | else { 28 | return -1; 29 | } 30 | } 31 | 32 | int ConcreteAggreaget::GetSize() { 33 | return SIZE; 34 | } 35 | 36 | 37 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/IteratorPattern/Aggregate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Iterator; 4 | typedef int Object; 5 | 6 | class Aggregate { 7 | public: 8 | Aggregate(); 9 | virtual ~Aggregate(); 10 | //virtual Iterator* CreateIterator() = 0; 11 | virtual Object GetItem(int idx) = 0; 12 | virtual int GetSize() = 0; 13 | }; 14 | 15 | class ConcreteAggreaget :public Aggregate { 16 | public: 17 | enum { SIZE = 3 }; 18 | ConcreteAggreaget(); 19 | //Iterator* CreateIterator(); 20 | Object GetItem(int idx); 21 | int GetSize(); 22 | private: 23 | Object _objs[SIZE]; 24 | }; 25 | 26 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/IteratorPattern/Iterator.cpp: -------------------------------------------------------------------------------- 1 | #include "Iterator.h" 2 | 3 | 4 | Iterator::Iterator() { 5 | } 6 | 7 | 8 | Iterator::~Iterator() { 9 | } 10 | 11 | ConcreteIterator::ConcreteIterator(Aggregate *ag, int idx = 0) { 12 | _ag = ag; 13 | _idx = idx; 14 | } 15 | 16 | Object ConcreteIterator::CurrentItem() { 17 | return _ag->GetItem(_idx); 18 | } 19 | 20 | void ConcreteIterator::First() { 21 | _idx = 0; 22 | } 23 | 24 | void ConcreteIterator::Next() { 25 | if (_idx < _ag->GetSize()) { 26 | _idx++; 27 | } 28 | } 29 | 30 | bool ConcreteIterator::IsDone() { 31 | return (_idx == _ag->GetSize()); 32 | } -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/IteratorPattern/Iterator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Aggregate.h" 3 | 4 | class Iterator { 5 | public: 6 | Iterator(); 7 | virtual ~Iterator(); 8 | virtual void First() = 0; 9 | virtual void Next() = 0; 10 | virtual bool IsDone() = 0; 11 | virtual Object CurrentItem() = 0; 12 | }; 13 | 14 | class ConcreteIterator :public Iterator { 15 | public: 16 | ConcreteIterator(Aggregate *ag, int idx /* = 0 */); 17 | 18 | void First(); 19 | void Next(); 20 | bool IsDone(); 21 | Object CurrentItem(); 22 | private: 23 | Aggregate* _ag; 24 | int _idx; 25 | }; 26 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/IteratorPattern/IteratorPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Aggregate.h" 3 | #include "Iterator.h" 4 | using namespace std; 5 | 6 | int main() { 7 | Aggregate* ag = new ConcreteAggreaget(); 8 | Iterator *it = new ConcreteIterator(ag, 0); 9 | for (; !(it->IsDone()); it->Next()) { 10 | cout << it->CurrentItem() << endl; 11 | } 12 | delete it; 13 | delete ag; 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/IteratorPattern/IteratorPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 源文件 23 | 24 | 25 | 源文件 26 | 27 | 28 | 29 | 30 | 头文件 31 | 32 | 33 | 头文件 34 | 35 | 36 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/MediatorPattern/MediatorPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | class Person; 5 | 6 | class Mediator { 7 | public: 8 | virtual void Send(const string& msg, Person* person) = 0; 9 | 10 | virtual ~Mediator() { } 11 | 12 | void BuildRelation(Person *a, Person *b) { 13 | m_a = a; 14 | m_b = b; 15 | } 16 | 17 | protected: 18 | Person *m_a; 19 | Person *m_b; 20 | }; 21 | 22 | class ConcreteMediator :public Mediator { 23 | public: 24 | void Send(const string& msg, Person* person) { 25 | if (person == m_a) { 26 | cout << msg << "--Mediator--PersonB" << endl; 27 | } 28 | else if (person == m_b) { 29 | cout << msg << "--Mediator--PersonA" << endl; 30 | } 31 | } 32 | }; 33 | 34 | class Person { 35 | public: 36 | Person(Mediator*md):_md(md) { } 37 | virtual void SendMessage(const string& msg) = 0; 38 | virtual ~Person() { } 39 | protected: 40 | Mediator* _md; 41 | }; 42 | 43 | class ConcretePersonA :public Person { 44 | public: 45 | ConcretePersonA(Mediator* md):Person(md) { } 46 | 47 | void SendMessage(const string& msg) { 48 | _md->Send(msg, this); 49 | } 50 | 51 | }; 52 | 53 | class ConcretePersonB :public Person { 54 | public: 55 | ConcretePersonB(Mediator* md):Person(md) { } 56 | 57 | void SendMessage(const string& msg) { 58 | _md->Send(msg, this); 59 | } 60 | }; 61 | 62 | int main() { 63 | Mediator *mediator = new ConcreteMediator(); 64 | Person *personA = new ConcretePersonA(mediator); 65 | Person *personB = new ConcretePersonB(mediator); 66 | 67 | mediator->BuildRelation(personA, personB); 68 | personA->SendMessage("PersonA"); 69 | personB->SendMessage("PersonB"); 70 | 71 | delete personA; 72 | delete personB; 73 | delete mediator; 74 | 75 | return 0; 76 | } 77 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/MediatorPattern/MediatorPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/MementoPattern/MementoPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | class Memento { 6 | private: 7 | friend class Originator; 8 | 9 | Memento(const string& st) { 10 | _st = st; 11 | } 12 | 13 | void SetState(const string& st) { 14 | _st = st; 15 | } 16 | 17 | string GetState() { 18 | return _st; 19 | } 20 | 21 | private: 22 | string _st; 23 | }; 24 | 25 | class Originator { 26 | public: 27 | Originator() { 28 | _mt = nullptr; 29 | } 30 | 31 | Originator(const string &st) { 32 | _st = st; 33 | _mt = nullptr; 34 | } 35 | 36 | Memento* CreateMemento() { 37 | return new Memento(_st); 38 | } 39 | 40 | void SetMemento(Memento* mt) { 41 | _mt = mt; 42 | } 43 | 44 | void RestoreToMemento(Memento* mt) { 45 | _st = mt->GetState(); 46 | } 47 | 48 | string GetState() { 49 | return _st; 50 | } 51 | 52 | void SetState(const string& st) { 53 | _st = st; 54 | } 55 | 56 | void PrintState() { 57 | cout << _st << "..." << endl; 58 | } 59 | 60 | private: 61 | string _st; 62 | Memento *_mt; 63 | }; 64 | 65 | int main() { 66 | Originator *o = new Originator(); 67 | o->SetState("old"); 68 | o->PrintState(); 69 | Memento *m = o->CreateMemento(); 70 | o->SetState("new"); 71 | o->PrintState(); 72 | o->RestoreToMemento(m); 73 | o->PrintState(); 74 | 75 | delete o; 76 | delete m; 77 | 78 | return 0; 79 | } 80 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/MementoPattern/MementoPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/ObserverPattern/Observer.cpp: -------------------------------------------------------------------------------- 1 | #include "Observer.h" 2 | #include "Subject.h" 3 | 4 | Observer::~Observer() { } 5 | 6 | Observer::Observer() { } 7 | 8 | Subject* ConcreteObserver::GetSubject() { 9 | return _sub; 10 | } 11 | 12 | ConcreteObserver::ConcreteObserver(Subject* sub) { 13 | _sub = sub; 14 | _sub->Attach(this); 15 | } 16 | 17 | ConcreteObserver::~ConcreteObserver() { 18 | _sub->Detach(this); 19 | //if (_sub != nullptr) { 20 | // delete _sub; 21 | //} 22 | } 23 | 24 | void ConcreteObserver::Update(Subject* sub) { 25 | _st = sub->GetState(); 26 | PrintInfo(); 27 | } 28 | 29 | void ConcreteObserver::PrintInfo() { 30 | cout << "ConcreteObserver::PrintInfo\t" << _sub->GetState() << endl; 31 | } 32 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/ObserverPattern/Observer.h: -------------------------------------------------------------------------------- 1 | #ifndef OBSERVER_H 2 | #define OBSERVER_H 3 | 4 | #include 5 | #include 6 | #include "Subject.h" 7 | using namespace std; 8 | 9 | class Observer { 10 | public: 11 | virtual void Update(Subject* sub) = 0; 12 | virtual void PrintInfo() = 0; 13 | virtual ~Observer(); 14 | protected: 15 | Observer(); 16 | string _st; 17 | }; 18 | 19 | class ConcreteObserver :public Observer { 20 | public: 21 | virtual Subject* GetSubject(); 22 | 23 | ConcreteObserver(Subject* sub); 24 | 25 | ~ConcreteObserver(); 26 | 27 | void Update(Subject* sub); 28 | 29 | void PrintInfo(); 30 | 31 | private: 32 | Subject *_sub; 33 | }; 34 | 35 | #endif //OBSERVER_H -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/ObserverPattern/ObserverPattern.cpp: -------------------------------------------------------------------------------- 1 | #include "Subject.h" 2 | #include "Observer.h" 3 | 4 | int main() { 5 | Subject *sub = new ConcreteSubject(); 6 | Observer *o1 = new ConcreteObserver(sub); 7 | Observer *o2 = new ConcreteObserver(sub); 8 | 9 | sub->SetState("old"); 10 | sub->Notify(); 11 | sub->SetState("new"); 12 | sub->Notify(); 13 | 14 | delete o1; 15 | delete o2; 16 | delete sub; 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/ObserverPattern/ObserverPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 源文件 23 | 24 | 25 | 源文件 26 | 27 | 28 | 29 | 30 | 源文件 31 | 32 | 33 | 源文件 34 | 35 | 36 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/ObserverPattern/Subject.cpp: -------------------------------------------------------------------------------- 1 | #include "Observer.h" 2 | #include "Subject.h" 3 | 4 | void Subject::Attach(Observer* obv) { 5 | _obvs.push_front(obv); 6 | } 7 | 8 | void Subject::Detach(Observer* obv) { 9 | if (obv != nullptr) { 10 | _obvs.remove(obv); 11 | } 12 | } 13 | 14 | void Subject::Notify() { 15 | for (auto obv : _obvs) { 16 | obv->Update(this); 17 | } 18 | } 19 | 20 | Subject::~Subject() { } 21 | 22 | Subject::Subject() { 23 | //_obvs.clear(); 24 | } 25 | 26 | string ConcreteSubject::GetState() { 27 | return _st; 28 | } 29 | 30 | void ConcreteSubject::SetState(const string& st) { 31 | _st = st; 32 | } 33 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/ObserverPattern/Subject.h: -------------------------------------------------------------------------------- 1 | #ifndef SUBJECT_H 2 | #define SUBJECT_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class Observer; 9 | 10 | using namespace std; 11 | 12 | class Subject { 13 | public: 14 | virtual void SetState(const string& st) = 0; 15 | virtual string GetState() = 0; 16 | 17 | virtual void Attach(Observer* obv); 18 | 19 | virtual void Detach(Observer* obv); 20 | 21 | virtual void Notify(); 22 | 23 | virtual ~Subject(); 24 | protected: 25 | Subject(); 26 | private: 27 | list _obvs; 28 | }; 29 | 30 | class ConcreteSubject :public Subject { 31 | public: 32 | string GetState(); 33 | 34 | void SetState(const string& st); 35 | private: 36 | string _st; 37 | }; 38 | 39 | #endif// SUBJECT_H 40 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/PrototypePattern/PrototypePattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | // Prototype 5 | 6 | class Prototype { 7 | public: 8 | virtual Prototype* Clone() = 0; 9 | virtual ~Prototype() { } 10 | }; 11 | 12 | class ConcretePrototype :public Prototype { 13 | public: 14 | ConcretePrototype() { } 15 | 16 | ConcretePrototype(const ConcretePrototype&cp) { 17 | cout << "ConcretePrototype copy..." << endl; 18 | } 19 | 20 | Prototype* Clone() { 21 | return new ConcretePrototype(*this); 22 | } 23 | }; 24 | 25 | int main() { 26 | Prototype *prototype = new ConcretePrototype(); 27 | cout << prototype << endl; 28 | Prototype* prototype1 = prototype->Clone(); 29 | cout << prototype1 << endl; 30 | Prototype* prototype2 = prototype->Clone(); 31 | cout << prototype2 << endl; 32 | 33 | delete prototype; 34 | delete prototype1; 35 | delete prototype2; 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/PrototypePattern/PrototypePattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/ProxyPattern/ProxyPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Subject { 5 | public: 6 | virtual void Request() = 0; 7 | virtual ~Subject() { } 8 | }; 9 | 10 | class ConcreteSubject :public Subject { 11 | public: 12 | void Request() { 13 | cout << "ConcreteSubject::Request..." << endl; 14 | } 15 | }; 16 | 17 | class Proxy { 18 | public: 19 | Proxy(Subject* subject) { 20 | _sub = subject; 21 | } 22 | 23 | void Reuqest() { 24 | cout << "Proxy::Request..." << endl; 25 | _sub->Request(); 26 | } 27 | 28 | private: 29 | Subject *_sub; 30 | }; 31 | 32 | int main() { 33 | Subject *sub = new ConcreteSubject(); 34 | Proxy *p = new Proxy(sub); 35 | p->Reuqest(); 36 | 37 | delete sub; 38 | delete p; 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/ProxyPattern/ProxyPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/README.md: -------------------------------------------------------------------------------- 1 | # 23种设计模式的C++实现 2 | 3 | **每个文件夹对应一个设计模式** 4 | 5 | *NOTE:为方便学习,大多数project仅有一个实现文件,class均以inline方式实现* 6 | 7 | **实现参考**: 8 | 9 | [设计模式精解-GoF 23种设计模式解析](http://www.baidu.com/link?url=LeHLAfOFv93jO50Prk0fPct7wpAB3UfdCgZERe_UB6nkd75tb0roib7eJ7xGKPzIVcvhndajzaO0UPbIsqe8uNKAHjk-W9BFJzo6U0mmIkm) 10 | 11 | *NOTE:源代码经过简化,移除了一些不必要的构造和析构函数,方便阅读* 12 | 13 | # 编译 14 | 15 | ## Visual Studio 2013(MSVC 12) 16 | 使用 Visual Studio 导入项目即可编译 17 | 18 | ## Linux or Mac OSX 19 | Linux 或 Mac OSX 环境使用 cmake 编译 20 | 21 | ```bash 22 | $ cd /path/to/project 23 | $ mkdir build 24 | $ cd build 25 | $ cmake .. 26 | $ make 27 | ``` -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/SingletonPattern/SingletonPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Singleton { 5 | public: 6 | static Singleton& Instance() { 7 | static Singleton instance; 8 | return instance; 9 | } 10 | 11 | private: 12 | Singleton() {} 13 | Singleton(const Singleton &another) {} 14 | }; 15 | 16 | 17 | int main() { 18 | Singleton &singleton1 = Singleton::Instance(); 19 | Singleton &singleton2 = Singleton::Instance(); 20 | 21 | cout << &singleton1 << endl; 22 | cout << &singleton2 << endl; 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/SingletonPattern/SingletonPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/StatePattern/StatePattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/StrategyPattern/StrategyPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Strategy { 5 | public: 6 | virtual void Interface() = 0; 7 | virtual ~Strategy() { } 8 | }; 9 | 10 | class ConcreteStrategyA :public Strategy { 11 | public: 12 | void Interface() { 13 | cout << "ConcreteStrategyA::Interface..." << endl; 14 | } 15 | }; 16 | 17 | class ConcreteStrategyB :public Strategy { 18 | public: 19 | void Interface() { 20 | cout << "ConcreteStrategyB::Interface..." << endl; 21 | } 22 | }; 23 | 24 | class Context { 25 | public: 26 | Context(Strategy *stg) { 27 | _stg = stg; 28 | } 29 | 30 | void DoAction() { 31 | _stg->Interface(); 32 | } 33 | 34 | private: 35 | Strategy *_stg; 36 | }; 37 | 38 | int main() { 39 | Strategy *ps = new ConcreteStrategyA(); 40 | Context *pc = new Context(ps); 41 | pc->DoAction(); 42 | 43 | delete pc; 44 | delete ps; 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/StrategyPattern/StrategyPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/TemplatePattern/TemplatePattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class AbstractClass { 5 | public: 6 | virtual void TemplateMethod() { 7 | PrimitiveOperation1(); 8 | PrimitiveOperation2(); 9 | } 10 | 11 | virtual ~AbstractClass() { } 12 | protected: 13 | virtual void PrimitiveOperation1() = 0; 14 | virtual void PrimitiveOperation2() = 0; 15 | AbstractClass() { } 16 | }; 17 | 18 | class ConcreteClass1 :public AbstractClass { 19 | public: 20 | void PrimitiveOperation1() { 21 | cout << "ConcreteClass1::PrimitiveOperation1" << endl; 22 | } 23 | 24 | void PrimitiveOperation2() { 25 | cout << "ConcreteClass1::PrimitiveOperation2" << endl; 26 | } 27 | }; 28 | 29 | class ConcreteClass2 :public AbstractClass { 30 | public: 31 | void PrimitiveOperation1() { 32 | cout << "ConcreteClass2::PrimitiveOperation1" << endl; 33 | } 34 | 35 | void PrimitiveOperation2() { 36 | cout << "ConcreteClass2::PrimitiveOperation2" << endl; 37 | } 38 | }; 39 | 40 | 41 | 42 | int main() { 43 | AbstractClass *p1 = new ConcreteClass1(); 44 | AbstractClass *p2 = new ConcreteClass2(); 45 | p1->TemplateMethod(); 46 | p2->TemplateMethod(); 47 | 48 | delete p1; 49 | delete p2; 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/TemplatePattern/TemplatePattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/VisitorPattern/Element.cpp: -------------------------------------------------------------------------------- 1 | #include "Element.h" 2 | #include 3 | using namespace std; 4 | 5 | Element::Element() { 6 | } 7 | 8 | Element::~Element() { 9 | } 10 | 11 | void ConcreteElementA::Accept(Visitor* vis) { 12 | vis->VisitConcreteElementA(this); 13 | cout << "visiting ConcreteElementA..." << endl; 14 | } 15 | 16 | void ConcreteElementB::Accept(Visitor* vis) { 17 | vis->VisitConcreteElementB(this); 18 | cout << "visiting ConcreteElementA..." << endl; 19 | } 20 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/VisitorPattern/Element.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Visitor.h" 3 | class Visitor; 4 | 5 | class Element { 6 | public: 7 | Element(); 8 | virtual ~Element(); 9 | virtual void Accept(Visitor* vis) = 0; 10 | }; 11 | 12 | class ConcreteElementA :public Element { 13 | public: 14 | void Accept(Visitor* vis); 15 | }; 16 | 17 | class ConcreteElementB :public Element { 18 | public: 19 | void Accept(Visitor* vis); 20 | }; -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/VisitorPattern/Visitor.cpp: -------------------------------------------------------------------------------- 1 | #include "Visitor.h" 2 | #include 3 | using namespace std; 4 | 5 | Visitor::Visitor() { 6 | } 7 | 8 | Visitor::~Visitor() { 9 | } 10 | 11 | void ConcreteVisitorA::VisitConcreteElementA(Element* elm) { 12 | cout << "i will visit ConcreteElementA..." << endl; 13 | } 14 | 15 | void ConcreteVisitorA::VisitConcreteElementB(Element* elm) { 16 | cout << "i will visit ConcreteElementB..." << endl; 17 | } 18 | 19 | void ConcreteVisitorB::VisitConcreteElementA(Element* elm) { 20 | cout << "i will visit ConcreteElementA..." << endl; 21 | } 22 | 23 | void ConcreteVisitorB::VisitConcreteElementB(Element* elm) { 24 | cout << "i will visit ConcreteElementB..." << endl; 25 | 26 | } -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/VisitorPattern/Visitor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Element.h" 4 | class Element; 5 | 6 | class Visitor { 7 | public: 8 | virtual ~Visitor(); 9 | 10 | virtual void VisitConcreteElementA(Element* elm) = 0; 11 | virtual void VisitConcreteElementB(Element* elm) = 0; 12 | protected: 13 | Visitor(); 14 | }; 15 | 16 | class ConcreteVisitorA :public Visitor { 17 | public: 18 | void VisitConcreteElementA(Element* elm); 19 | void VisitConcreteElementB(Element* elm); 20 | }; 21 | 22 | class ConcreteVisitorB :public Visitor { 23 | public: 24 | void VisitConcreteElementA(Element* elm); 25 | void VisitConcreteElementB(Element* elm); 26 | }; 27 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/VisitorPattern/VisitorPattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Element.h" 3 | #include "Visitor.h" 4 | using namespace std; 5 | 6 | int main() { 7 | Visitor *vis = new ConcreteVisitorA(); 8 | Element *elm = new ConcreteElementA(); 9 | elm->Accept(vis); 10 | 11 | delete elm; 12 | delete vis; 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/DesignPattern_FullList/VisitorPattern/VisitorPattern.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 源文件 23 | 24 | 25 | 源文件 26 | 27 | 28 | 29 | 30 | 头文件 31 | 32 | 33 | 头文件 34 | 35 | 36 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_messenger/messenger_demo.pro: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # Automatically generated by qmake (3.1) Thu Oct 21 16:52:45 2021 3 | ###################################################################### 4 | 5 | TEMPLATE = app 6 | TARGET = messenger_demo 7 | INCLUDEPATH += . 8 | LIBS += -lpthread 9 | 10 | # The following define makes your compiler warn you if you use any 11 | # feature of Qt which has been marked as deprecated (the exact warnings 12 | # depend on your compiler). Please consult the documentation of the 13 | # deprecated API in order to know how to port your code away from it. 14 | DEFINES += QT_DEPRECATED_WARNINGS 15 | 16 | # You can also make your code fail to compile if you use deprecated APIs. 17 | # In order to do so, uncomment the following line. 18 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 19 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 20 | 21 | # Input 22 | HEADERS += Messenger.h Svar.h 23 | SOURCES += \ 24 | complex_demo.cpp \ 25 | simple_demo.cpp 26 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_messenger/simple_demo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Svar.h" 4 | #include "Messenger.h" 5 | 6 | ///This file is a simple demo for messenger communication using normal callback function 7 | 8 | using namespace std; 9 | using namespace GSLAM; 10 | 11 | 12 | 13 | 14 | //callback function to be called in subscriber 15 | void callBackFunc(string msg) 16 | { 17 | cout << "Normal function is printing message: \n" << msg << endl; 18 | } 19 | 20 | void callBackFunc(int num) 21 | { 22 | cout << "Normal function is printing message: \n" << msg << endl; 23 | } 24 | 25 | 26 | int main(int argc, char** argv) 27 | { 28 | svar.ParseMain(argc, argv); 29 | //Do communications simply 30 | 31 | //define topic 32 | string topicSimple = svar.GetString("ActSimple", "printMsg"); 33 | int queueSize = 0; 34 | 35 | //create subscriber 36 | auto subSimple = messenger.subscribe(topicSimple, queueSize, callBackFunc); 37 | 38 | //create publisher 39 | auto pubSimple = messenger.advertise(topicSimple, queueSize); 40 | 41 | //publish message 42 | string simpleMsg = "This is a simple msg sent in main funciton."; 43 | pubSimple.publish(simpleMsg); 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/.gitignore: -------------------------------------------------------------------------------- 1 | CMakeLists.txt.* 2 | build 3 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/GSLAM/Display.h: -------------------------------------------------------------------------------- 1 | #ifndef GSLAM_DISPLAY_H 2 | #define GSLAM_DISPLAY_H 3 | 4 | #include "Messenger.h" 5 | 6 | namespace GSLAM { 7 | 8 | 9 | 10 | class DisplayProperty{ 11 | public: 12 | DisplayProperty(const Svar& value, 13 | const Svar& callback=Svar(), 14 | const std::string& describe="") 15 | :_value(value),_callback(callback),_describe(describe){} 16 | 17 | void refresh(){if(_refresh.isFunction()) _refresh();} 18 | 19 | void notify(){if(_callback.isFunction()) _callback();} 20 | 21 | Svar _value,_callback,_refresh; 22 | std::string _describe; 23 | }; 24 | 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/README.md: -------------------------------------------------------------------------------- 1 | # 面向对象的系统设计 2 | 3 | 本示例程序通过一个无人机系统的通信、控制、仿真,演示如何设计系统架构,各种类的定义,接口设计。 4 | 5 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/linux64/FindGLEW.cmake: -------------------------------------------------------------------------------- 1 | #.rst: 2 | # FindGLEW 3 | # -------- 4 | # 5 | # Find the OpenGL Extension Wrangler Library (GLEW) 6 | # 7 | # IMPORTED Targets 8 | # ^^^^^^^^^^^^^^^^ 9 | # 10 | # This module defines the :prop_tgt:`IMPORTED` target ``GLEW::GLEW``, 11 | # if GLEW has been found. 12 | # 13 | # Result Variables 14 | # ^^^^^^^^^^^^^^^^ 15 | # 16 | # This module defines the following variables: 17 | # 18 | # :: 19 | # 20 | # GLEW_INCLUDE_DIRS - include directories for GLEW 21 | # GLEW_LIBRARIES - libraries to link against GLEW 22 | # GLEW_FOUND - true if GLEW has been found and can be used 23 | 24 | #============================================================================= 25 | # Copyright 2012 Benjamin Eikel 26 | # 27 | # Distributed under the OSI-approved BSD License (the "License"); 28 | # see accompanying file Copyright.txt for details. 29 | # 30 | # This software is distributed WITHOUT ANY WARRANTY; without even the 31 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 32 | # See the License for more information. 33 | #============================================================================= 34 | # (To distribute this file outside of CMake, substitute the full 35 | # License text for the above reference.) 36 | 37 | set(GLEW_FOUND true) 38 | set(GLEW_VERSION 1.13.0) 39 | set(GLEW_INCLUDES ${CMAKE_CURRENT_LIST_DIR}/glew-1.13.0/include) 40 | set(GLEW_LIBS ${CMAKE_CURRENT_LIST_DIR}/glew-1.13.0/lib/libGLEW.a) 41 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/linux64/FindQt.cmake: -------------------------------------------------------------------------------- 1 | # Install qt5 for Linux 2 | # sudo apt-get install qt5-doc qt5-default libqt5opengl5 libqt5svg5-dev 3 | 4 | set(CMAKE_PREFIX_PATH D:/Qt/Qt5.9.4/5.9.4/msvc2017_64) # enable this line to decide which version of Qt to find 5 | #set(CMAKE_PREFIX_PATH /home/bushuhui/pis/RTMapper3/dev_soft/third_party/qt-4.8.5_install) 6 | 7 | find_package(Qt5) 8 | 9 | if(QT4_FOUND) 10 | set(QT_INCLUDES ${QT_INCLUDE_DIR}) 11 | set(QT_LIBRARIES Qt4::QtCore Qt4::QtGui Qt4::QtNetwork Qt4::QtOpenGL Qt4::QtSvg Qt4::QtSql Qt4::QtXml) 12 | set(QT_FOUND true) 13 | set(QT4_FOUND true) 14 | set(QT_VERSION 4) 15 | else() 16 | find_package(Qt5 COMPONENTS Core Gui Widgets Network OpenGL Svg Sql Xml REQUIRED) 17 | set(QT_INCLUDES ${_qt5Core_install_prefix}/include) 18 | set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Network Qt5::OpenGL Qt5::Svg Qt5::Sql Qt5::Xml) 19 | set(QT_FOUND true) 20 | set(QT5_FOUND true) 21 | set(QT_VERSION "${PACKAGE_VERSION}") 22 | endif() 23 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/linux64/FindSystem.cmake: -------------------------------------------------------------------------------- 1 | set(SYSTEM_FOUND 1) 2 | 3 | IF(WIN32) 4 | set(SYSTEM_LIBRARIES pthread Iphlpapi wsock32 Ws2_32 Vfw32 Winmm Comctl32) 5 | ELSE(WIN32) 6 | set(SYSTEM_LIBRARIES pthread dl X11) 7 | 8 | if(TCMALLOC_ENABLED) 9 | set(SYSTEM_LIBRARIES pthread dl tcmalloc) 10 | endif() 11 | 12 | # for static Qt 13 | #set(SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} z m gthread-2.0 glib-2.0 rt freetype gobject-2.0 glib-2.0 SM ICE Xrender fontconfig freetype Xext X11 ) 14 | ENDIF(WIN32) 15 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/linux64/glew-1.13.0/lib/libGLEW.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/linux64/glew-1.13.0/lib/libGLEW.a -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/vs2015x64/FindGLEW.cmake: -------------------------------------------------------------------------------- 1 | set(GLEW_VERSION 1.13.0) 2 | set(GLEW_INCLUDES ${CMAKE_CURRENT_LIST_DIR}/glew-1.13.0/include) 3 | set(GLEW_LIBS ${CMAKE_CURRENT_LIST_DIR}/glew-1.13.0/lib/Release/x64/libglew32.lib) 4 | set(GLEW_FOUND true) -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/vs2015x64/FindOPENGL.cmake: -------------------------------------------------------------------------------- 1 | set(OpenGL_FOUND 1) 2 | 3 | if( WIN32) 4 | set(OPENGL_LIBRARIES opengl32 glu32) 5 | #set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /mingw64/lib) 6 | else( WIN32 ) 7 | set(OPENGL_LIBRARIES GL GLU glut GLEW) 8 | endif( WIN32) 9 | 10 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/vs2015x64/FindQt.cmake: -------------------------------------------------------------------------------- 1 | #set(CMAKE_PREFIX_PATH D:/Qt/Qt5.6.3/5.6.3/msvc2015_64) # enable this line to decide which version of Qt to find 2 | set(CMAKE_PREFIX_PATH E:/Qt/Qt5.6.3/5.6.3/msvc2015_64) 3 | 4 | find_package(Qt4) 5 | 6 | if(QT4_FOUND) 7 | set(QT_INCLUDES ${QT_INCLUDE_DIR}) 8 | set(QT_LIBRARIES Qt4::QtCore Qt4::QtGui Qt4::QtNetwork Qt4::QtOpenGL Qt4::QtSvg Qt4::QtSql Qt4::QtXml) 9 | set(QT_FOUND true) 10 | set(QT4_FOUND true) 11 | set(QT_VERSION 4) 12 | else() 13 | find_package(Qt5 COMPONENTS Core Gui Widgets Network OpenGL Svg Sql Xml REQUIRED) 14 | set(QT_INCLUDES ${_qt5Core_install_prefix}/include) 15 | set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Network Qt5::OpenGL Qt5::Svg Qt5::Sql Qt5::Xml) 16 | set(QT_FOUND true) 17 | set(QT5_FOUND true) 18 | set(QT_VERSION "${PACKAGE_VERSION}") 19 | endif() 20 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/vs2015x64/FindSystem.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(SYSTEM_FOUND 1) 3 | 4 | IF(WIN32) 5 | set(SYSTEM_LIBRARIES Iphlpapi wsock32 Ws2_32 Vfw32 Winmm Comctl32) 6 | #set(SYSTEM_LIBRARIES pthread Iphlpapi Ws2_32) 7 | ELSE(WIN32) 8 | set(SYSTEM_LIBRARIES pthread dl) 9 | ENDIF(WIN32) 10 | 11 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/vs2015x64/glew-1.13.0/lib/Release/Win32/glew32.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/vs2015x64/glew-1.13.0/lib/Release/Win32/glew32.exp -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/vs2015x64/glew-1.13.0/lib/Release/Win32/glew32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/vs2015x64/glew-1.13.0/lib/Release/Win32/glew32.lib -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/vs2015x64/glew-1.13.0/lib/Release/x64/libglew32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/vs2015x64/glew-1.13.0/lib/Release/x64/libglew32.lib -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/vs2015x64/shared_export.map: -------------------------------------------------------------------------------- 1 | { 2 | global: 3 | createRTMapperInstance; 4 | exportTileManager; 5 | *SvarWithType*; 6 | main; 7 | local: *; 8 | }; 9 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/cmake/vs2015x64/static_export.sym: -------------------------------------------------------------------------------- 1 | main 2 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/src/comm.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMM_H__ 2 | #define __COMM_H__ 3 | 4 | #include "GSLAM.h" 5 | #include "Svar.h" 6 | 7 | #include 8 | 9 | namespace GSLAM { 10 | 11 | /** 12 | * @brief The Communication Base class 13 | * 14 | */ 15 | class CommunicationBase : public GObject 16 | { 17 | public: 18 | CommunicationBase() {} 19 | virtual ~CommunicationBase() {} 20 | 21 | virtual void call(const std::string& command,void* arg=NULL){} 22 | virtual std::string type()const{return "CommunicationBase";} 23 | 24 | virtual int openDevice(Svar& conf); 25 | virtual int read(std::vector& buf, int buf_len); 26 | virtual int write(std::vector& buf); 27 | }; 28 | 29 | 30 | /** 31 | * @brief The UDP Communication class 32 | * 33 | */ 34 | class CommunicationUDP : public CommunicationBase 35 | { 36 | CommunicationUDP() {} 37 | virtual ~CommunicationUDP() {} 38 | 39 | virtual void call(const std::string& command,void* arg=NULL){} 40 | virtual std::string type()const{return "CommunicationUDP";} 41 | 42 | virtual int openDevice(Svar& conf); 43 | virtual int read(std::vector& buf, int buf_len); 44 | virtual int write(std::vector& buf); 45 | }; 46 | 47 | } // end of namespace GSLAM 48 | 49 | #endif // end of __COMM_H__ 50 | 51 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/src/control.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/5_advanced/4_DesignPattern_UML/sample_oo-design/src/control.h -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/src/datalink_protocol.h: -------------------------------------------------------------------------------- 1 | #ifndef __DATALINK_PROTOCOL_H__ 2 | #define __DATALINK_PROTOCOL_H__ 3 | 4 | #include "GSLAM.h" 5 | #include "uav.h" 6 | 7 | namespace GSLAM 8 | { 9 | 10 | class Datalink_Protocol : public GObject 11 | { 12 | public: 13 | Datalink_Protocol() {} 14 | virtual ~Datalink_Protocol() {} 15 | 16 | 17 | /** 18 | * @brief parse data buffer to generate UAV data package 19 | * @param buf - buffer pointer 20 | * @param buflen - buffer length 21 | * @return 0 - parse success, other - failed 22 | */ 23 | virtual int parse_fromBuf(UavData& uav, uint8_t *buf, int buflen) = 0; 24 | 25 | 26 | /** 27 | * @brief parse data buffer to generate UAV data package 28 | * @param buf - buffer object 29 | * @return 0 - parse success, other - failed 30 | */ 31 | virtual int parse_fromBuf(UavData& uav, std::vector& buf) = 0; 32 | 33 | 34 | /** 35 | * @brief generate given UAV command's data buffer 36 | * @param cmd - command 37 | * @param buf - generated data buffer 38 | * @param parm - other parameters 39 | * @return 0 - success, other - failed 40 | */ 41 | virtual int package_toBuf(UavData& uav, 42 | const std::string& cmd, std::vector& buf, 43 | Svar* parm=NULL) = 0; 44 | 45 | }; 46 | 47 | 48 | } 49 | 50 | 51 | #endif // end of __DATALINK_PROTOCOL_H__ 52 | 53 | 54 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_oo-design/src/simulation.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/5_advanced/4_DesignPattern_UML/sample_oo-design/src/simulation.h -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_parameters/Default.json: -------------------------------------------------------------------------------- 1 | { 2 | "num" : 20, 3 | "books" : [ 4 | {"name" : "C++ Primer", "url" : "http://a.com" }, 5 | {"name" : "Design Pattern", "url" : "http://b.com" } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_parameters/ParameterDemo.pro: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # Automatically generated by qmake (3.1) Mon Oct 18 21:56:50 2021 3 | ###################################################################### 4 | 5 | TEMPLATE = app 6 | TARGET = ParameterDemo 7 | 8 | INCLUDEPATH += . 9 | 10 | # The following define makes your compiler warn you if you use any 11 | # feature of Qt which has been marked as deprecated (the exact warnings 12 | # depend on your compiler). Please consult the documentation of the 13 | # deprecated API in order to know how to port your code away from it. 14 | DEFINES += QT_DEPRECATED_WARNINGS 15 | 16 | # You can also make your code fail to compile if you use deprecated APIs. 17 | # In order to do so, uncomment the following line. 18 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 19 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 20 | 21 | # Input 22 | HEADERS += src/Svar.h 23 | SOURCES += src/ParameterDemo.cpp 24 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_parameters/src/ParameterDemo.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "Svar.h" 4 | 5 | 6 | int do_print(void) 7 | { 8 | // 如果程序其他部分没有设置 `nprint`值,则会使用3作为其数值 9 | int nprint = svar.GetInt("nprint", 3); 10 | for(int i=0; iact("hello"); 11 | pb->act("world"); 12 | 13 | return 0; 14 | } 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | test_plugin(); 19 | 20 | return 0; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_plugin/src/PluginImplA.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "PluginDef.h" 3 | 4 | 5 | //////////////////////////////////////////////////////////////////////////////// 6 | //////////////////////////////////////////////////////////////////////////////// 7 | 8 | class PluginA : public PluginBase 9 | { 10 | public: 11 | PluginA() {} 12 | virtual ~PluginA() {} 13 | 14 | virtual int act(const std::string& cmd, void *args=nullptr) { 15 | printf("[PluginA] cmd = %s\n", cmd.c_str()); 16 | return 0; 17 | } 18 | 19 | }; 20 | 21 | REGISTER_PLUGIN(PluginA, PluginA) 22 | 23 | 24 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/sample_plugin/src/PluginImplB.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "PluginDef.h" 3 | 4 | 5 | //////////////////////////////////////////////////////////////////////////////// 6 | //////////////////////////////////////////////////////////////////////////////// 7 | 8 | class PluginB : public PluginBase 9 | { 10 | public: 11 | PluginB() {} 12 | virtual ~PluginB() {} 13 | 14 | virtual int act(const std::string& cmd, void *args=nullptr) { 15 | printf("[PluginB] cmd = %s\n", cmd.c_str()); 16 | return 0; 17 | } 18 | 19 | }; 20 | 21 | REGISTER_PLUGIN(PluginB, PluginB) 22 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/svar_module/README.md: -------------------------------------------------------------------------------- 1 | # 模块化编程 2 | 3 | ## 什么是模块化编程 4 | 5 | 随着程序规模越来越大,将所有的功能集中到一个单体程序,会引起很多问题: 6 | * 名字空间冲突 7 | * 库版本冲突 8 | * 不容易维护、管理 9 | 10 | 为了让程序更好维护、开发,需要将程序分解成一些相对独立的模块。每个模块需要明确的输入输出,有清晰的接口,相对独立的实现 11 | 12 | ## 为什么要模块化编程 13 | 14 | 为了提高程序的复用性,降低程序内部的耦合性,模块化设计使得模块可以在其他项目中使用 15 | * 适合团体协作开发。 16 | * 模块化设计将项目分解为几个较小的项目,每人负责一部分。 17 | * 团队成员不需要了解整个系统。 18 | 19 | 20 | ## 基于Svar的模块化编程 21 | 22 | SVar通过C++11的特性,将C++中的静态类型进行包裹,从而能够动态加载、生成。此外,SVar作为容器,能够保存变量、函数、类,方便模块的使用,也能让动态语言例如Python调用。 23 | 24 | * [Svar基本使用](svar_basic) 25 | * [Svar插件使用](svar_plugin) 26 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/svar_module/other/redefine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(redefine) 3 | 4 | include(cmake/PICMake.cmake) 5 | 6 | set(CMAKE_CXX_STANDARD 17) 7 | if(NOT CMAKE_BUILD_TYPE) 8 | set(CMAKE_BUILD_TYPE Release) 9 | endif() 10 | 11 | INCLUDE_DIRECTORIES(src) 12 | 13 | pi_add_target(a BIN src/a.cpp src/b.cpp REQUIRED System) 14 | pi_report_target() 15 | 16 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/svar_module/other/redefine/cmake/FindOPENGL.cmake: -------------------------------------------------------------------------------- 1 | set(OpenGL_FOUND 1) 2 | set(OPENGL_LIBRARIES GL GLU glut GLEW) 3 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/svar_module/other/redefine/cmake/FindQt.cmake: -------------------------------------------------------------------------------- 1 | #find_package(Qt4) 2 | 3 | if(QT4_FOUND) 4 | set(QT_INCLUDES ${QT_INCLUDE_DIR}) 5 | set(QT_LIBRARIES Qt4::QtCore Qt4::QtGui Qt4::QtNetwork Qt4::QtOpenGL Qt4::QtSvg Qt4::QtSql Qt4::QtXml) 6 | set(QT_FOUND true) 7 | set(QT4_FOUND true) 8 | set(QT_VERSION 4) 9 | else() 10 | find_package(Qt5 COMPONENTS Core Gui Widgets Network OpenGL Svg Sql Xml) 11 | set(QT_INCLUDES ${_qt5Core_install_prefix}/include) 12 | set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Network Qt5::OpenGL Qt5::Svg Qt5::Sql Qt5::Xml) 13 | set(QT_FOUND true) 14 | set(QT5_FOUND true) 15 | set(QT_VERSION "${PACKAGE_VERSION}") 16 | endif() 17 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/svar_module/other/redefine/cmake/FindSystem.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(SYSTEM_FOUND 1) 3 | 4 | IF(WIN32) 5 | set(SYSTEM_LIBRARIES Iphlpapi wsock32 Ws2_32 Vfw32 Winmm Comctl32) 6 | #set(SYSTEM_LIBRARIES pthread Iphlpapi Ws2_32) 7 | ELSE(WIN32) 8 | set(SYSTEM_LIBRARIES pthread dl) 9 | ENDIF(WIN32) 10 | 11 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/svar_module/other/redefine/cmake/PICMake.cmake.in: -------------------------------------------------------------------------------- 1 | include(@CMAKE_CURRENT_LIST_DIR@/cmake/PICMake.cmake) 2 | 3 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/svar_module/other/redefine/src/a.cpp: -------------------------------------------------------------------------------- 1 | 2 | double add(double a , double b){ 3 | return a+b; 4 | } 5 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/svar_module/other/redefine/src/b.cpp: -------------------------------------------------------------------------------- 1 | 2 | double add(double a , double b){ 3 | return a+b; 4 | } 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/svar_module/other/redefine_b/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(redefine_b) 3 | 4 | include(cmake/PICMake.cmake) 5 | 6 | set(CMAKE_CXX_STANDARD 17) 7 | if(NOT CMAKE_BUILD_TYPE) 8 | set(CMAKE_BUILD_TYPE Release) 9 | endif() 10 | 11 | INCLUDE_DIRECTORIES(src) 12 | 13 | pi_add_target(a SHARED src/a.cpp REQUIRED System) 14 | pi_add_target(b SHARED src/b.cpp REQUIRED System) 15 | pi_add_target(m BIN src/main.cpp DEPENDENCY ${CMAKE_CURRENT_LIST_DIR}/build/libb.dll ${CMAKE_CURRENT_LIST_DIR}/build/liba.dll ) 16 | pi_report_target() 17 | 18 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/svar_module/other/redefine_b/cmake/FindOPENGL.cmake: -------------------------------------------------------------------------------- 1 | set(OpenGL_FOUND 1) 2 | set(OPENGL_LIBRARIES GL GLU glut GLEW) 3 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/svar_module/other/redefine_b/cmake/FindQt.cmake: -------------------------------------------------------------------------------- 1 | #find_package(Qt4) 2 | 3 | if(QT4_FOUND) 4 | set(QT_INCLUDES ${QT_INCLUDE_DIR}) 5 | set(QT_LIBRARIES Qt4::QtCore Qt4::QtGui Qt4::QtNetwork Qt4::QtOpenGL Qt4::QtSvg Qt4::QtSql Qt4::QtXml) 6 | set(QT_FOUND true) 7 | set(QT4_FOUND true) 8 | set(QT_VERSION 4) 9 | else() 10 | find_package(Qt5 COMPONENTS Core Gui Widgets Network OpenGL Svg Sql Xml) 11 | set(QT_INCLUDES ${_qt5Core_install_prefix}/include) 12 | set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Network Qt5::OpenGL Qt5::Svg Qt5::Sql Qt5::Xml) 13 | set(QT_FOUND true) 14 | set(QT5_FOUND true) 15 | set(QT_VERSION "${PACKAGE_VERSION}") 16 | endif() 17 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/svar_module/other/redefine_b/cmake/FindSystem.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(SYSTEM_FOUND 1) 3 | 4 | IF(WIN32) 5 | set(SYSTEM_LIBRARIES Iphlpapi wsock32 Ws2_32 Vfw32 Winmm Comctl32) 6 | #set(SYSTEM_LIBRARIES pthread Iphlpapi Ws2_32) 7 | ELSE(WIN32) 8 | set(SYSTEM_LIBRARIES pthread dl) 9 | ENDIF(WIN32) 10 | 11 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/svar_module/other/redefine_b/cmake/PICMake.cmake.in: -------------------------------------------------------------------------------- 1 | include(@CMAKE_CURRENT_LIST_DIR@/cmake/PICMake.cmake) 2 | 3 | -------------------------------------------------------------------------------- /5_advanced/4_DesignPattern_UML/svar_module/other/redefine_b/src/a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double add(double a , double b){ 4 | std::cout<<__FILE__< 2 | 3 | double add(double a , double b){ 4 | std::cout<<__FILE__< 2 | 3 | double add(double a , double b); 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | std::cout< 11 | double addtwo(double a,double b); 12 | double addtwo(double a,double b){ 13 | return a+b; 14 | } 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | sv::Svar add = svar.import("add"); 19 | double t = add["addtwo"](1,2).castAs(); 20 | LOG(INFO)< 3 | 4 | using namespace sv; 5 | 6 | void c_func_demo(Svar arg){ 7 | std::cout<<"Calling a c_func with arg "<("Person","The base class") 39 | .construct() 40 | .def("intro",&Person::intro) 41 | .def_static("all",&Person::all_person) 42 | .def("age",&Person::age) 43 | .def_readonly("name",&Person::_name,"The name of a person"); 44 | 45 | // use the class with svar 46 | Svar Person=svar["Person"]; 47 | 48 | std::cout<(); 49 | 50 | 51 | Svar father=Person(40,"father"); 52 | Svar mother=Person(39,"mother"); 53 | 54 | 55 | std::cout<<"all:"<()< 3 | 4 | double add(double a , double b){ 5 | std::cout<<__FILE__< 3 | 4 | double add(double a , double b){ 5 | std::cout<<__FILE__< 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | sv::Svar a = svar.import("a"); 7 | sv::Svar b = svar.import("b"); 8 | std::cout< 3 | #include 4 | 5 | coroutine::Channel channel; 6 | 7 | string async_func() 8 | { 9 | std::this_thread::sleep_for(std::chrono::milliseconds(3000)); 10 | return "22"; 11 | } 12 | 13 | void routine_func1() 14 | { 15 | int i = channel.pop(); 16 | std::cout << i << std::endl; 17 | 18 | i = channel.pop(); 19 | std::cout << i << std::endl; 20 | } 21 | 22 | void routine_func2(int i) 23 | { 24 | std::cout << "20" << std::endl; 25 | coroutine::yield(); 26 | 27 | std::cout << "21" << std::endl; 28 | 29 | //run function async 30 | //yield current routine if result not returned 31 | string str = coroutine::await(async_func); 32 | std::cout << str << std::endl; 33 | } 34 | 35 | void thread_func() 36 | { 37 | //create routine with callback like std::function 38 | coroutine::routine_t rt1 = coroutine::create(routine_func1); 39 | coroutine::routine_t rt2 = coroutine::create(std::bind(routine_func2, 2)); 40 | 41 | std::cout << "00" << std::endl; 42 | coroutine::resume(rt1); 43 | 44 | std::cout << "01" << std::endl; 45 | coroutine::resume(rt2); 46 | 47 | std::cout << "02" << std::endl; 48 | channel.push(10); 49 | 50 | std::cout << "03" << std::endl; 51 | coroutine::resume(rt2); 52 | 53 | std::cout << "04" << std::endl; 54 | channel.push(11); 55 | 56 | std::cout << "05" << std::endl; 57 | 58 | std::this_thread::sleep_for(std::chrono::milliseconds(6000)); 59 | coroutine::resume(rt2); 60 | 61 | //destroy routine, free resouce allocated 62 | //Warning: don't destroy routine by itself 63 | coroutine::destroy(rt1); 64 | coroutine::destroy(rt2); 65 | } 66 | 67 | int main() 68 | { 69 | std::thread t1(thread_func); 70 | std::thread t2([](){ 71 | //unsupport coordinating routine crossing threads 72 | }); 73 | t1.join(); 74 | t2.join(); 75 | return 0; 76 | } 77 | 78 | -------------------------------------------------------------------------------- /5_advanced/5_MultiThread/producer_consumer/producer_consumer.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2021-04-06T23:06:08 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core 8 | 9 | 10 | TARGET = producer_consumer 11 | TEMPLATE = app 12 | 13 | # The following define makes your compiler emit warnings if you use 14 | # any feature of Qt which has been marked as deprecated (the exact warnings 15 | # depend on your compiler). Please consult the documentation of the 16 | # deprecated API in order to know how to port your code away from it. 17 | DEFINES += QT_DEPRECATED_WARNINGS 18 | 19 | # You can also make your code fail to compile if you use deprecated APIs. 20 | # In order to do so, uncomment the following line. 21 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 22 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 23 | 24 | 25 | SOURCES += \ 26 | producer_consumer.cpp 27 | 28 | HEADERS += 29 | 30 | -------------------------------------------------------------------------------- /5_advanced/6_Debug/backward/README.md: -------------------------------------------------------------------------------- 1 | ## Backward堆栈回溯使用简单指南 2 | 3 | > last update: 2022-04-25 4 | 5 | ### 简单指南 6 | 7 | 按照`backward.cpp`的提示安装库并链接即可 8 | 9 | ### 详细指南(linux) 10 | 11 | 1. 将`backward.cpp`和`backward.hpp`包含在项目中 12 | 2. 安装依赖 13 | 14 | ```sh 15 | ## 必须安装的依赖 16 | sudo apt install libunwind-dev # -lunwind 17 | 18 | ## 下面的库任选一个安装 19 | sudo apt install binutils-dev # -lbfd 该库已经过测试可以使用 20 | sudo apt install libdw-dev # -ldw 21 | sudo apt install libdwarf-dev # -ldwarf 22 | ``` 23 | 24 | 3. 在`backward.cpp`中将你安装的依赖库对应的宏**取消注释**,例如`#define BACKWARD_HAS_LIBUNWIND 1` 25 | 26 | 4. 在编译时链接你安装的依赖库,例如`-lunwind`等 27 | 28 | 5. 并在编译时链接必需的依赖库`-g`和`-ldl`,以及以防万一的`-rdynamic`(”让链接器将所有符号添加到动态符号表中”) 29 | 30 | ```shell 31 | # 已安装binutils-dev和libunwind-dev库 32 | g++ test_stacktrace.cpp backward.cpp -lbfd -lunwind -ldl -g -rdynamic 33 | ``` 34 | 35 | [源码库链接](https://github.com/bombela/backward-cpp)上面有更为详细的介绍和自定义backtrace格式的说明,可以参考修改对应内容 36 | 37 | -------------------------------------------------------------------------------- /5_advanced/6_Debug/backward/backward.cpp: -------------------------------------------------------------------------------- 1 | // Pick your poison. 2 | // 3 | // On GNU/Linux, you have few choices to get the most out of your stack trace. 4 | // 5 | // By default you get: 6 | // - object filename 7 | // - function name 8 | // 9 | // In order to add: 10 | // - source filename 11 | // - line and column numbers 12 | // - source code snippet (assuming the file is accessible) 13 | 14 | // Install one of the following libraries then uncomment one of the macro (or 15 | // better, add the detection of the lib and the macro definition in your build 16 | // system) 17 | 18 | // - apt-get install libdw-dev ... 19 | // - g++/clang++ -ldw ... 20 | // #define BACKWARD_HAS_DW 1 21 | 22 | // - apt-get install binutils-dev ... 23 | // - g++/clang++ -lbfd ... 24 | // #define BACKWARD_HAS_BFD 1 25 | 26 | // - apt-get install libdwarf-dev ... 27 | // - g++/clang++ -ldwarf ... 28 | // #define BACKWARD_HAS_DWARF 1 29 | 30 | // Regardless of the library you choose to read the debug information, 31 | // for potentially more detailed stack traces you can use libunwind 32 | // - apt-get install libunwind-dev 33 | // - g++/clang++ -lunwind 34 | // #define BACKWARD_HAS_LIBUNWIND 1 35 | 36 | #include "backward.hpp" 37 | 38 | namespace backward { 39 | 40 | backward::SignalHandling sh; 41 | 42 | } // namespace backward 43 | -------------------------------------------------------------------------------- /5_advanced/6_Debug/backward/test_backward.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char *argv[]) 4 | { 5 | int *p = NULL; 6 | 7 | *p = 10; 8 | 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /5_advanced/programming_standard/Google_Cpp_Style_guide_CN.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/5_advanced/programming_standard/Google_Cpp_Style_guide_CN.pdf -------------------------------------------------------------------------------- /5_advanced/programming_standard/Google_Cpp_Style_guide_CN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/5_advanced/programming_standard/Google_Cpp_Style_guide_CN.png -------------------------------------------------------------------------------- /5_advanced/programming_standard/README.md: -------------------------------------------------------------------------------- 1 | # 编码规范 2 | 3 | ![Google_Cpp_Style_guide_CN.png](Google_Cpp_Style_guide_CN.png) -------------------------------------------------------------------------------- /6_adv_projects/README.md: -------------------------------------------------------------------------------- 1 | # Stage 6 - 高级项目 2 | 3 | 通过复杂、高级项目牵引来学习更高级的技巧等。 4 | 5 | * SLAM的实现是一类复杂的程序,包括数学、操作系统、多线程、C++、STL、CMake、大量第三方库等等,因此通过学习SLAM能够掌握复杂软件系统的设计、程序高级技巧,有了这些能力与技巧,后续做其他项目就会变得简单。**因此学习SLAM对个人的综合能力的提升有着非常显著的作用,希望大家能够脚踏实地、一步一步去学习。** 6 | * 复杂的项目除了使用较多的数据结构、算法等,另外有很多的概念、处理流程,如何将诸多的变量、函数、类有效的管理起来,从而实现低耦合、通用接口、方便易用是需要考虑的技术点。可以深入学习[《设计模式与UML》](../5_advanced/4_DesignPattern_UML),以及示例程序,学会如何将设计模式应用到自己编写的程序。 7 | 8 | 9 | 10 | ## 1. 示例项目 11 | 12 | 具体的学习牵引项目如下所列,可以思考如何自己独立自主实现下面所示例的项目。 13 | 14 | * [FastGCS无人机地面站](https://gitee.com/pi-lab/FastGCS):能够支持航线飞行、定点飞行的无人机地面站,整合了无人机实时地图、无人机飞行仿真 15 | * [PI-SLAM](https://gitee.com/pi-lab/pi-slam) : 智能系统实验室开发的插件化SLAM系统,能够学习视觉SLAM编程 16 | * [Map2DFusion](https://gitee.com/pi-lab/Map2DFusion) : 实时二维地图拼接,通过视觉SLAM解算位姿,并增量式拼接二维地图 17 | * [序列化图像的SfM重建](https://gitee.com/pi-lab/SequenceSfM) : 本实例程序演示了如何编写基本的SfM程序,通过利用序列化数据的特点加快重建的速度 18 | 19 | -------------------------------------------------------------------------------- /6_tools/README.md: -------------------------------------------------------------------------------- 1 | # 编程工具与技巧 2 | 3 | 熟练掌握编程工具对于提高工作、研究效率起到至关重要的作用,也许对于你解决一个问题需要一周时间,而对于经验丰富的人可能1-2分钟就解决了,所以效率的差别是难以想想的巨大。如果在各个点上都能以比较高的效率去学习、工作,则可以腾出很多时间去学更高级的东西,或者合理休息从而更进一步提高效率。 4 | 5 | ## 1. [Linux](linux) 6 | Linux操作系统下面有非常多的开发工具,特别对于计算视觉、机器学习,大量的开源代码基于Linux开发,熟练的使用Linux能极大的加快试错的速度。 7 | 8 | 9 | 10 | ## 2. [Git](git) 11 | 12 | `Git`是非常重要的一种协作工具,支持多人同时围绕一个项目进行协作。当然Git主要的功能是版本管理,能够把自己做过的改进等都记录下来。 13 | 14 | 15 | 16 | ## 3. [Markdown](markdown) 17 | 18 | `Markdown`作为一个非常重要的文本格式,使用非常简单的标记来实现最常用的文档格式。 19 | 20 | 21 | 22 | ## 4. [CMake](cmake) 23 | 24 | 对于复杂的C++项目,通过CMake管理项目的编译,能够做到更高效,此外大量的开源软件使用CMake,因此熟练掌握CMake能够极大地加快尝试其他人程序的速度。 25 | 26 | 27 | 28 | ## 5. [Debug](debug) 29 | 30 | 程序一般都会有问题,如何有效的将程序中的错误定位,并修改是一项非常重要的技能,熟练掌握Debug技能,能极大的加快开发的速度。 31 | -------------------------------------------------------------------------------- /6_tools/cmake/1_CMake/simple_exe/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | PROJECT (simple_exe) 4 | 5 | SET(SRC_LIST src/simple_exe.cpp) 6 | ADD_EXECUTABLE(simple_exe ${SRC_LIST}) 7 | 8 | -------------------------------------------------------------------------------- /6_tools/cmake/1_CMake/simple_exe/src/simple_exe.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char *argv[]) 4 | { 5 | std::cout << "hello world!" << std::endl; 6 | 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /6_tools/cmake/1_CMake/simple_sharedlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | PROJECT (simple_sharedlib) 4 | 5 | INCLUDE_DIRECTORIES(utils) 6 | 7 | # add lib target 8 | SET(LIB_SRC_LIST utils/utils.cpp) 9 | ADD_LIBRARY(utils SHARED ${LIB_SRC_LIST}) 10 | 11 | # add exe target 12 | SET(EXE_SRC_LIST src/simple_sharedlib.cpp) 13 | ADD_EXECUTABLE(simple_sharedlib ${EXE_SRC_LIST}) 14 | TARGET_LINK_LIBRARIES(simple_sharedlib utils) 15 | 16 | -------------------------------------------------------------------------------- /6_tools/cmake/1_CMake/simple_sharedlib/src/simple_sharedlib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "utils.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | // call lib's function 8 | int sum = add(10, 20); 9 | std::cout << " 10 + 20 = " << sum << std::endl; 10 | 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /6_tools/cmake/1_CMake/simple_sharedlib/utils/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | int add(int i1, int i2) 4 | { 5 | return i1+i2; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /6_tools/cmake/1_CMake/simple_sharedlib/utils/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef __UTILS_H__ 2 | #define __UTILS_H__ 3 | 4 | int add(int i1, int i2); 5 | 6 | #endif // end of __UTILS_H__ 7 | -------------------------------------------------------------------------------- /6_tools/cmake/1_CMake/simple_staticlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | PROJECT (simple_staticlib) 4 | 5 | INCLUDE_DIRECTORIES(utils) 6 | 7 | # add lib target 8 | SET(LIB_SRC_LIST utils/utils.cpp) 9 | ADD_LIBRARY(utils STATIC ${LIB_SRC_LIST}) 10 | 11 | # add exe target 12 | SET(EXE_SRC_LIST src/simple_staticlib.cpp) 13 | ADD_EXECUTABLE(simple_staticlib ${EXE_SRC_LIST}) 14 | TARGET_LINK_LIBRARIES(simple_staticlib utils) 15 | 16 | -------------------------------------------------------------------------------- /6_tools/cmake/1_CMake/simple_staticlib/src/simple_staticlib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "utils.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | // call lib's function 8 | int sum = add(10, 20); 9 | std::cout << " 10 + 20 = " << sum << std::endl; 10 | 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /6_tools/cmake/1_CMake/simple_staticlib/utils/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | int add(int i1, int i2) 4 | { 5 | return i1+i2; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /6_tools/cmake/1_CMake/simple_staticlib/utils/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef __UTILS_H__ 2 | #define __UTILS_H__ 3 | 4 | int add(int i1, int i2); 5 | 6 | #endif // end of __UTILS_H__ 7 | -------------------------------------------------------------------------------- /6_tools/cmake/2_PICMake/simple_exe/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | PROJECT (simple_exe) 4 | 5 | include(PICMake.cmake) 6 | 7 | pi_add_target(simple_exe BIN src/simple_exe.cpp) 8 | 9 | pi_report_targets() 10 | -------------------------------------------------------------------------------- /6_tools/cmake/2_PICMake/simple_exe/src/simple_exe.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char *argv[]) 4 | { 5 | std::cout << "hello world!" << std::endl; 6 | 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /6_tools/cmake/2_PICMake/simple_sharedlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.5) 3 | 4 | PROJECT (simple_sharedlib) 5 | 6 | LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) 7 | include(cmake/PICMake.cmake) 8 | 9 | 10 | INCLUDE_DIRECTORIES(utils) 11 | 12 | pi_add_target(utils SHARED utils/utils.cpp) 13 | 14 | pi_add_target(simple_sharedlib BIN src/simple_sharedlib.cpp REQUIRED Utils) 15 | 16 | pi_report_targets() 17 | 18 | -------------------------------------------------------------------------------- /6_tools/cmake/2_PICMake/simple_sharedlib/cmake/FindUtils.cmake: -------------------------------------------------------------------------------- 1 | set(UTILS_FOUND 1) 2 | 3 | set(UTILS_LIBRARIES utils) 4 | 5 | -------------------------------------------------------------------------------- /6_tools/cmake/2_PICMake/simple_sharedlib/src/simple_sharedlib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "utils.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | // call lib's function 8 | int sum = add(10, 20); 9 | std::cout << " 10 + 20 = " << sum << std::endl; 10 | 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /6_tools/cmake/2_PICMake/simple_sharedlib/utils/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | int add(int i1, int i2) 4 | { 5 | return i1+i2; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /6_tools/cmake/2_PICMake/simple_sharedlib/utils/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef __UTILS_H__ 2 | #define __UTILS_H__ 3 | 4 | int add(int i1, int i2); 5 | 6 | #endif // end of __UTILS_H__ 7 | -------------------------------------------------------------------------------- /6_tools/cmake/2_PICMake/simple_staticlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.5) 3 | 4 | PROJECT (simple_staticlib) 5 | 6 | LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) 7 | include(cmake/PICMake.cmake) 8 | 9 | 10 | INCLUDE_DIRECTORIES(utils) 11 | 12 | pi_add_target(utils STATIC utils/utils.cpp) 13 | 14 | pi_add_target(simple_staticlib BIN src/simple_staticlib.cpp REQUIRED Utils) 15 | 16 | pi_report_targets() 17 | 18 | -------------------------------------------------------------------------------- /6_tools/cmake/2_PICMake/simple_staticlib/cmake/FindUtils.cmake: -------------------------------------------------------------------------------- 1 | set(UTILS_FOUND 1) 2 | 3 | set(UTILS_LIBRARIES utils) 4 | 5 | -------------------------------------------------------------------------------- /6_tools/cmake/2_PICMake/simple_staticlib/src/simple_staticlib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "utils.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | // call lib's function 8 | int sum = add(10, 20); 9 | std::cout << " 10 + 20 = " << sum << std::endl; 10 | 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /6_tools/cmake/2_PICMake/simple_staticlib/utils/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | int add(int i1, int i2) 4 | { 5 | return i1+i2; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /6_tools/cmake/2_PICMake/simple_staticlib/utils/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef __UTILS_H__ 2 | #define __UTILS_H__ 3 | 4 | int add(int i1, int i2); 5 | 6 | #endif // end of __UTILS_H__ 7 | -------------------------------------------------------------------------------- /6_tools/cmake/README.md: -------------------------------------------------------------------------------- 1 | # Cmake 2 | 3 | ## 一、 Cmake概述 4 | 5 | ### 1.Cmake的由来? 6 | 当我们要执行程序前要对程序进行编译,然而Make工具却有很多种,如 GNU Make ,QT 的 qmake ,微软的 MS nmake,BSD Make(pmake),Makepp,等等。这些 Make 工具遵循着不同的规范和标准,所执行的 Makefile 格式也千差万别。这样就带来了一个严峻的问题:如果软件想跨平台,必须要保证能够在不同平台编译。而如果使用上面的 Make 工具,就得为每一种标准写一次 Makefile。所以为了避免这样的跨平台问题,Cmake就被设计了出来。 7 | 8 | ### 1.什么是Cmake 9 | CMake是一个跨平台的安装(编译)工具,它允许开发者编写一种与平台无关的 CMakeList.txt 文件来定制整个编译流程,然后再根据用户的平台进一步生成所需的本地化 Makefile 和工程文件。 10 | 11 | ### 1.3 在 linux 平台下使用 CMake 生成 Makefile 并编译的流程 12 | 13 | 1. 编写 CMake 配置文件 CMakeLists.txt 。 14 | 2. 执行命令 cmake PATH 生成 Makefile。其中, PATH 是 CMakeLists.txt 所在的目录。 15 | 3. 使用 make 命令进行编译。 16 | 17 | 18 | ## 二、课程内容 19 | 1.[单个源文件下CMakeList.txt](./单个源文件下Cmake.md) 20 | 21 | 2.[工程下CMakeList.txt](./工程下Cmake.md) 22 | 23 | 3.[静态库与动态库构建与安装](./静态库与动态库构建与安装.md) 24 | 25 | 4.[CMake变量](./CMake变量.md) 26 | 27 | 5.[CMake常用指令](./CMake常用指令.md) 28 | 29 | 6.[模块的使用和自定义模块](./模块的使用和自定义模块.md) 30 | 31 | 32 | 33 | ## 三、推荐资料 34 | 35 | * [CMake 入门实战](http://www.hahack.com/codes/cmake/) 36 | * [cmake教程.pdf](./cmake教程.pdf) 37 | * [CMake 学习笔记](http://blog.csdn.net/dbzhang800/article/details/6314073) 38 | 39 | 赵勇师兄的PICMake(CMake的简化版?建议掌握CMake之后看一下) 40 | [PICMake](https://github.com/zdzhaoyong/PICMake) 41 | 42 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT (HELLO) 2 | SET(SRC_LIST main.c) 3 | MESSAGE(STATUS "This is BINARY dir " ${HELLO_BINARY_DIR}) 4 | MESSAGE(STATUS "This is SOURCE dir " ${HELLO_SOURCE_DIR}) 5 | ADD_EXECUTABLE(hello ${SRC_LIST}) 6 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t1/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | printf("Hello World from t1 Main!\n"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t2/.idea/.name: -------------------------------------------------------------------------------- 1 | HELLO -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t2/.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t2/.idea/dictionaries/oem.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t2/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t2/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t2/.idea/t2.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | PROJECT(HELLO) 3 | ADD_SUBDIRECTORY(src) 4 | INSTALL(FILES README.md DESTINATION share/doc/cmake/t2) 5 | INSTALL(DIRECTORY doc/ DESTINATION share/doc/cmake/t2) 6 | INSTALL(PROGRAMS runhello.sh DESTINATION bin) 7 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t2/README.md: -------------------------------------------------------------------------------- 1 | readme hello world -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t2/doc/hello.txt: -------------------------------------------------------------------------------- 1 | hello world 2 | 3 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t2/runhello.sh: -------------------------------------------------------------------------------- 1 | hello 2 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t2/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_EXECUTABLE(hello main.c) 2 | set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t2/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | printf("Hello World from t2 Main!\n"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t3/.idea/.name: -------------------------------------------------------------------------------- 1 | HELLOLIB -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t3/.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t3/.idea/dictionaries/oem.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t3/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t3/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t3/.idea/t3.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.3) 2 | PROJECT(HELLOLIB) 3 | ADD_SUBDIRECTORY(lib) 4 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t3/lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(LIBHELLO_SRC hello.c) 2 | ADD_LIBRARY(hello SHARED ${LIBHELLO_SRC}) #添加动态库 3 | #ADD_LIBRARY(hello STATIC ${LIBHELLO_SRC}) #添加静态库 4 | ADD_LIBRARY(hello_static STATIC ${LIBHELLO_SRC}) 5 | SET_TARGET_PROPERTIES(hello_static PROPERTIES OUTPUT_NAME "hello") #更改静态库输出名字 6 | #GET_TARGET_PROPERTY(OUTPUT_VALUE hello_static OUTPUT_NAME) #获取静态库输出名字 7 | #MESSAGE(STATUS “This is the hello_static OUTPUT_NAME:”${OUTPUT_VALUE}) 8 | SET_TARGET_PROPERTIES(hello PROPERTIES VERSION 1.2 SOVERSION 1) #设置动态库版本号 9 | #INSTALL(TARGETS hello hello_static LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) #安装静态库与动态库 10 | #INSTALL(FILES hello.h DESTINATION include/hello) #安装头文件 11 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t3/lib/hello.c: -------------------------------------------------------------------------------- 1 | #include "hello.h" 2 | void HelloFunc() 3 | { 4 | printf("Hello World\n"); 5 | } 6 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t3/lib/hello.h: -------------------------------------------------------------------------------- 1 | #ifndef HELLO_H 2 | #define HELLO_H 3 | #include 4 | void HelloFunc(); 5 | #endif 6 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t4/.idea/.name: -------------------------------------------------------------------------------- 1 | HELLO -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t4/.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t4/.idea/dictionaries/oem.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t4/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t4/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t4/.idea/t4.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t4/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | PROJECT (HELLO) 3 | SET(SRC_LIST main.cpp) 4 | 5 | INCLUDE_DIRECTORIES(cmake) 6 | 7 | SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) 8 | 9 | FIND_PACKAGE(OpenCV) 10 | 11 | INCLUDE_DIRECTORIES(${OPENCV_INCLUDE_DIR}) 12 | 13 | ADD_EXECUTABLE(hello ${SRC_LIST}) 14 | TARGET_LINK_LIBRARIES(hello ${OPENCV_LIBRARIES}) 15 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t4/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | cv::Mat image = cv::imread("../timg.jpeg"); 6 | if (!image.empty()) { 7 | cv::imshow("image", image); 8 | cv::waitKey(-1); 9 | } else { 10 | std::cout << "Can not get image." << std::endl; 11 | } 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/t4/timg.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/cmake/summercamp/t4/timg.jpeg -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/test/data.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/cmake/summercamp/test/data.txt -------------------------------------------------------------------------------- /6_tools/cmake/summercamp/test/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int main() 5 | { 6 | 7 | printf("Hello World from test Main!\n"); 8 | //#ifdef ENABLE_DEBUG 9 | #ifndef ENABLE_DEBUG 10 | printf("ENABLE_DEBUG is DEFINITED in CMakeList!"); 11 | #endif 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /6_tools/debug/backtrace/backtrace.pro: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # Automatically generated by qmake (3.1) Wed Mar 31 09:08:30 2021 3 | ###################################################################### 4 | 5 | TEMPLATE = app 6 | TARGET = backtrace 7 | INCLUDEPATH += . 8 | 9 | UI_DIR = ./build 10 | MOC_DIR = ./build 11 | OBJECTS_DIR = ./build 12 | 13 | # enable Debug mode 14 | # qmake backtrace.pro CONFIG+=debug 15 | 16 | # The following define makes your compiler warn you if you use any 17 | # feature of Qt which has been marked as deprecated (the exact warnings 18 | # depend on your compiler). Please consult the documentation of the 19 | # deprecated API in order to know how to port your code away from it. 20 | DEFINES += QT_DEPRECATED_WARNINGS 21 | 22 | # You can also make your code fail to compile if you use deprecated APIs. 23 | # In order to do so, uncomment the following line. 24 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 25 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 26 | 27 | # Input 28 | HEADERS += utils_debug.h 29 | SOURCES += test_backtrace.cpp utils_debug.cpp 30 | -------------------------------------------------------------------------------- /6_tools/debug/backtrace/test_backtrace.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "utils_debug.h" 5 | 6 | int test_func(void) 7 | { 8 | int *p = 0; 9 | 10 | *p = 10; 11 | return *p; 12 | } 13 | 14 | class DemoClass 15 | { 16 | public: 17 | DemoClass() { 18 | 19 | } 20 | 21 | int call_func(void) 22 | { 23 | test_func(); 24 | } 25 | }; 26 | 27 | int main(int argc, char *argv[]) 28 | { 29 | // setup stack backtrace 30 | dbg_stacktrace_setup(); 31 | 32 | DemoClass *c = new DemoClass; 33 | c->call_func(); 34 | 35 | return 0; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /6_tools/debug/backtrace/utils_debug.h: -------------------------------------------------------------------------------- 1 | #ifndef __UTILS_DEBUG_H__ 2 | #define __UTILS_DEBUG_H__ 3 | 4 | 5 | //////////////////////////////////////////////////////////////////////////////// 6 | /// ASSERT macro 7 | //////////////////////////////////////////////////////////////////////////////// 8 | #ifdef RTK_DEBUG 9 | 10 | #define ASSERT(f) \ 11 | do { \ 12 | if (!f ) { \ 13 | fprintf(stderr, "ERROR (FILE: %s, LINE: %d, FUNC: %s)\n", \ 14 | __FILE__, __LINE__, __FUNCTION__); \ 15 | exit(1); \ 16 | } \ 17 | } while (0); \ 18 | 19 | 20 | #define ASSERT2(f, s) \ 21 | do { \ 22 | if (!f ) { \ 23 | fprintf(stderr, "ERROR: %s (FILE: %s, LINE: %d, FUNC: %s)\n", \ 24 | s, __FILE__, __LINE__, __FUNCTION__); \ 25 | exit(1); \ 26 | } \ 27 | } while (0); \ 28 | 29 | #else 30 | #define ASSERT(f) 31 | #define ASSERT2(f, s) 32 | #endif 33 | 34 | 35 | //////////////////////////////////////////////////////////////////////////////// 36 | /// debug stack trace functions 37 | //////////////////////////////////////////////////////////////////////////////// 38 | 39 | int dbg_stacktrace_setup(void); 40 | 41 | 42 | 43 | #endif // end of __UTILS_DEBUG_H__ 44 | 45 | -------------------------------------------------------------------------------- /6_tools/debug/dbg-macro/README.md: -------------------------------------------------------------------------------- 1 | # dbg-macro 2 | 3 | [dbg-macro](https://github.com/sharkdp/dbg-macro) : 兼容 C++11 的 header-only 单个头文件的打日志方式调试库。它提供了比 printf 和 std::cout 更好的宏函数。特点: 4 | 5 | - 美观的彩色输出 6 | - 支持基础类型和 STL 容器类型的输出 7 | - 除了基本信息外,还输出变量名和类型 8 | 9 | 10 | 11 | 12 | 13 | 输出: 14 | 15 | ![dbg-macro](images/dbg-macro.png) 16 | 17 | 使用方法: 18 | ```C++ 19 | #include 20 | #include 21 | 22 | // You can use "dbg(..)" in expressions: 23 | int factorial(int n) { 24 | if (dbg(n <= 1)) { 25 | return dbg(1); 26 | } else { 27 | return dbg(n * factorial(n - 1)); 28 | } 29 | } 30 | 31 | int main() { 32 | std::string message = "hello"; 33 | dbg(message); // [example.cpp:15 (main)] message = "hello" (std::string) 34 | 35 | const int a = 2; 36 | const int b = dbg(3 * a) + 1; // [example.cpp:18 (main)] 3 * a = 6 (int) 37 | 38 | std::vector numbers{b, 13, 42}; 39 | dbg(numbers); // [example.cpp:21 (main)] numbers = {7, 13, 42} (std::vector) 40 | 41 | dbg("this line is executed"); // [example.cpp:23 (main)] this line is executed 42 | 43 | factorial(4); 44 | 45 | return 0; 46 | } 47 | ``` 48 | 49 | -------------------------------------------------------------------------------- /6_tools/debug/dbg-macro/images/dbg-macro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/debug/dbg-macro/images/dbg-macro.png -------------------------------------------------------------------------------- /6_tools/debug/images/backtrace_demo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/debug/images/backtrace_demo1.png -------------------------------------------------------------------------------- /6_tools/debug/images/backtrace_demo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/debug/images/backtrace_demo2.png -------------------------------------------------------------------------------- /6_tools/debug/images/qtcreator_debug_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/debug/images/qtcreator_debug_01.png -------------------------------------------------------------------------------- /6_tools/debug/images/qtcreator_debug_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/debug/images/qtcreator_debug_02.png -------------------------------------------------------------------------------- /6_tools/debug/images/qtcreator_debug_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/debug/images/qtcreator_debug_03.png -------------------------------------------------------------------------------- /6_tools/debug/images/qtcreator_debug_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/debug/images/qtcreator_debug_04.png -------------------------------------------------------------------------------- /6_tools/debug/images/qtcreator_debug_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/debug/images/qtcreator_debug_05.png -------------------------------------------------------------------------------- /6_tools/debug/images/qtcreator_debug_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/debug/images/qtcreator_debug_06.png -------------------------------------------------------------------------------- /6_tools/debug/log/log.pro: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # Automatically generated by qmake (2.01a) Wed Mar 31 10:32:23 2021 3 | ###################################################################### 4 | 5 | TEMPLATE = app 6 | TARGET = 7 | DEPENDPATH += . 8 | INCLUDEPATH += . 9 | 10 | 11 | UI_DIR = ./build 12 | MOC_DIR = ./build 13 | OBJECTS_DIR = ./build 14 | 15 | 16 | # Input 17 | HEADERS += fmt_format.h fmt_posix.h Glog.h Svar.h utils_debug.h 18 | SOURCES += fmt_format.cpp fmt_posix.cpp test_log.cpp utils_debug.cpp 19 | -------------------------------------------------------------------------------- /6_tools/debug/log/test_log.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "Glog.h" 6 | #include "fmt_format.h" 7 | #include "utils_debug.h" 8 | 9 | using namespace std; 10 | 11 | int test_fmt(void) 12 | { 13 | cout << fmt::printf("%s\n", "Hello world!"); 14 | return 0; 15 | } 16 | 17 | int test_log(void) 18 | { 19 | LOG(INFO) << fmt::printf("INFO message!\n"); 20 | LOG(WARNING) << fmt::printf("Warning message!\n"); 21 | LOG(ERROR) << fmt::printf("ERROR message!\n"); 22 | LOG(FATAL) << fmt::printf("FATAL message!\n"); 23 | 24 | return 0; 25 | } 26 | 27 | int main(int argc, char *argv[]) 28 | { 29 | dbg_stacktrace_setup(); 30 | 31 | test_fmt(); 32 | test_log(); 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /6_tools/debug/log/utils_debug.h: -------------------------------------------------------------------------------- 1 | #ifndef __UTILS_DEBUG_H__ 2 | #define __UTILS_DEBUG_H__ 3 | 4 | 5 | //////////////////////////////////////////////////////////////////////////////// 6 | /// ASSERT macro 7 | //////////////////////////////////////////////////////////////////////////////// 8 | #ifdef RTK_DEBUG 9 | 10 | #define ASSERT(f) \ 11 | do { \ 12 | if (!f ) { \ 13 | fprintf(stderr, "ERROR (FILE: %s, LINE: %d, FUNC: %s)\n", \ 14 | __FILE__, __LINE__, __FUNCTION__); \ 15 | exit(1); \ 16 | } \ 17 | } while (0); \ 18 | 19 | 20 | #define ASSERT2(f, s) \ 21 | do { \ 22 | if (!f ) { \ 23 | fprintf(stderr, "ERROR: %s (FILE: %s, LINE: %d, FUNC: %s)\n", \ 24 | s, __FILE__, __LINE__, __FUNCTION__); \ 25 | exit(1); \ 26 | } \ 27 | } while (0); \ 28 | 29 | #else 30 | #define ASSERT(f) 31 | #define ASSERT2(f, s) 32 | #endif 33 | 34 | 35 | //////////////////////////////////////////////////////////////////////////////// 36 | /// debug stack trace functions 37 | //////////////////////////////////////////////////////////////////////////////// 38 | 39 | int dbg_stacktrace_setup(void); 40 | 41 | 42 | 43 | #endif // end of __UTILS_DEBUG_H__ 44 | 45 | -------------------------------------------------------------------------------- /6_tools/debug/module_test/demo_test.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest.h" 2 | 3 | 4 | TEST(Demo,Test1) 5 | { 6 | printf("Hello demo test!\n"); 7 | } 8 | -------------------------------------------------------------------------------- /6_tools/debug/module_test/demo_test_main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "gtest.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | testing::InitGoogleTest(&argc, argv); 7 | return RUN_ALL_TESTS(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /6_tools/flickers/system/lightdm.conf: -------------------------------------------------------------------------------- 1 | [SeatDefaults] 2 | autologin-guest=false 3 | autologin-user=pilab 4 | autologin-user-timeout=0 5 | user-session=ubuntu 6 | # Uncomment the following, if running Unity 7 | #greeter-session=unity-greeter 8 | -------------------------------------------------------------------------------- /6_tools/flickers/system/supervisor/supervisord.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Process Monitoring and Control Daemon(Supervisor daemon) 3 | After=rc-local.service nss-user-lookup.target 4 | 5 | [Service] 6 | Type=forking 7 | ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf 8 | ExecStop=/usr/bin/supervisord shutdown 9 | ExecReload=/usr/bin/supervisord reload 10 | killMode=process 11 | Restart=on-failure 12 | RestartSec=42s 13 | 14 | [Install] 15 | WantedBy=multi-user.target 16 | -------------------------------------------------------------------------------- /6_tools/git/Git_remote_branch.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/Git_remote_branch.pdf -------------------------------------------------------------------------------- /6_tools/git/Git使用教程_PILAB.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/Git使用教程_PILAB.pdf -------------------------------------------------------------------------------- /6_tools/git/Git教程.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/Git教程.pdf -------------------------------------------------------------------------------- /6_tools/git/HowToForkClone.md: -------------------------------------------------------------------------------- 1 | # 如何Fork代码到自己的仓库并clone到本地 2 | 3 | 详见 [如何快速的注册账号并完成第一次提交](https://gitee.com/help/categories/19) 4 | 5 | ## 1. [注册 Gitee 账号](https://gitee.com/help/articles/4113) 6 | 7 | 如果没有注册Gitee账户,先注册一个账户。按照[注册 Gitee 账号](https://gitee.com/help/articles/4113)的说明操作。 8 | 9 | 10 | 11 | ## 2. [安装Git软件,配置环境](README.md) 12 | 13 | 按照[安装Git软件,配置环境](README.md),进行如下操作: 14 | 1. 安装 Git 15 | 2. 配置个人的基本信息 16 | 3. 设置SSH公钥 17 | 18 | 19 | 20 | ## 3. Fork仓库到自己的仓库 21 | 22 | 如下图所示,点击红色圈圈部分的`Fork` 23 | 24 | ![usage](pic_git/how_to_fork.png) 25 | 26 | 27 | 28 | ## 4. clone仓库到本地 29 | 30 | [git clone / 下载代码](https://gitee.com/help/articles/4192#article-header0) 31 | 32 | ![usage](pic_git/git_clone_code.png) 33 | 34 | 35 | 36 | 37 | 38 | ## 5. [提交第一行代码](https://gitee.com/help/articles/4122) 39 | 40 | 在自己的本地仓库进行修改,确认无误后,进入到本地参考的目录,执行 41 | ``` 42 | git add -A 43 | git commit -m "Message" 44 | git push origin master 45 | ``` 46 | 47 | 如果遇到问题,可以使用如下命令排查错误 48 | ``` 49 | # 查看仓库的服务器地址,确认是否是自己的地址;否则不是自己的仓库,没有权限push 50 | git remote -v 51 | 52 | # 查看仓库的具体信息 53 | git status 54 | ``` 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /6_tools/git/HowToPullRequest.md: -------------------------------------------------------------------------------- 1 | # 如何申请Pull Request 2 | 3 | 按照Git的标准操作,一般是自己Fork一个项目,然后在自己Fork项目里进行操作,如果希望将自己做的修改让母项目(之前被Fork的那个项目)更新,则可以通过Pull Request完成。通过发起`Pull Request`,母项目的开发人员可以通过Pull你自己项目的改动,从而将你的改进合并到母项目中。 4 | 5 | 为什么这么做?“Pull Request”是一种通知机制,你修改了他人的代码,将你修改通知原来的作者,希望他合并你的修改,这就是Pull Request。Pull Request本质上是一种软件合作方法,是将涉及不同功能的代码,纳入主干的一种流程。这个过程中,还可以进行讨论、审核和修改代码。更详细的说明可以参考[《Github中Pull Request操作》](https://www.jianshu.com/p/a31a888ac46b) (虽然讲的是Github,但是Gitee上的操作是类似的) 6 | 7 | 关于如何Fork,如何clone代码,可以参考[《如何Fork代码到自己的仓库并clone到本地》](HowToForkClone.md) 8 | 9 | 10 | 11 | ## 1. 在Fork的项目的本地修改代码,然后提交到服务器 12 | 13 | ``` 14 | git add -A 15 | git commit -m "Improve some descriptions" 16 | git push origin master 17 | ``` 18 | 19 | 20 | 21 | ## 2. 进入自己项目,选择`+Pull Request` 22 | 23 | 在gitee网站上,自己项目的主页上,找到`+Pull Request`(下图中红色标注的地方),然后点击 24 | 25 | ![pull request](pic_git/git_pull_request1.png) 26 | 27 | 28 | 29 | ## 2. 选择Target branch, 填写请求的说明 30 | 31 | * 选择目标分支信息,默认是母项目的仓库,`master`分支(下图中红色标注的,一般情况下不需要改) 32 | * 填写请求的说明(下图中蓝色标注的,简明写出改进了什么,做了什么等等) 33 | * 然后点击页面右下方的`Create` 34 | 35 | ![target_branch](pic_git/git_pull_request2.png) 36 | 37 | 38 | 39 | ## 3. 等待母项目开发人员确认并采纳 40 | 41 | * 如果你做的修改得到了母项目开发人员的认可,则他会将你做的修改合并进入到母项目 42 | 43 | * 如果他认为你做的不够好,则有可能会给你反馈,你根据反馈作为修改,然后再操作一次`Pull Request` -------------------------------------------------------------------------------- /6_tools/git/git-cheatsheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/git-cheatsheet.pdf -------------------------------------------------------------------------------- /6_tools/git/git-cheatsheet_cn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/git-cheatsheet_cn.jpg -------------------------------------------------------------------------------- /6_tools/git/gitee_addmember.md: -------------------------------------------------------------------------------- 1 | # 如何在Gitee项目中添加成员 2 | 3 | 为了方便大家协同开发、或者方便修改等,需要多人同时操作一个代码仓库。这就需要给代码仓库增加除了自己之外的人增加用户权限,具体的操作步骤如下: 4 | 5 | ## step1: 点击下面图片中右上角的`settings`菜单 6 | ![进入项目的设置](pic_git/gitee_addmember1.png) 7 | 8 | 9 | ## step2: 点击左侧的菜单栏中的`Members settings` - `All`,然后点击右侧上方的`Add member` 10 | ![进入项目的设置](pic_git/gitee_addmember2.png) 11 | 12 | 13 | ## step3: 生成邀请链接,并发送 14 | 点击右侧的`Copy Address`,将这个邀请地址发给 bushuhui@nwpu.edu.cn 15 | ![进入项目的设置](pic_git/gitee_addmember3.png) 16 | 17 | -------------------------------------------------------------------------------- /6_tools/git/gitignore.txt: -------------------------------------------------------------------------------- 1 | #Latex 2 | *.aux 3 | *.log 4 | *.bak 5 | *.sav 6 | *.bbl 7 | *.toc 8 | *.blg 9 | *.out 10 | main.pdf 11 | -------------------------------------------------------------------------------- /6_tools/git/pic_git/git1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/pic_git/git1.png -------------------------------------------------------------------------------- /6_tools/git/pic_git/git2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/pic_git/git2.png -------------------------------------------------------------------------------- /6_tools/git/pic_git/git3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/pic_git/git3.png -------------------------------------------------------------------------------- /6_tools/git/pic_git/git4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/pic_git/git4.png -------------------------------------------------------------------------------- /6_tools/git/pic_git/git5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/pic_git/git5.png -------------------------------------------------------------------------------- /6_tools/git/pic_git/git6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/pic_git/git6.png -------------------------------------------------------------------------------- /6_tools/git/pic_git/git7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/pic_git/git7.png -------------------------------------------------------------------------------- /6_tools/git/pic_git/git_clone_code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/pic_git/git_clone_code.png -------------------------------------------------------------------------------- /6_tools/git/pic_git/git_pull_request1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/pic_git/git_pull_request1.png -------------------------------------------------------------------------------- /6_tools/git/pic_git/git_pull_request2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/pic_git/git_pull_request2.png -------------------------------------------------------------------------------- /6_tools/git/pic_git/gitee_addmember1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/pic_git/gitee_addmember1.png -------------------------------------------------------------------------------- /6_tools/git/pic_git/gitee_addmember2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/pic_git/gitee_addmember2.png -------------------------------------------------------------------------------- /6_tools/git/pic_git/gitee_addmember3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/pic_git/gitee_addmember3.png -------------------------------------------------------------------------------- /6_tools/git/pic_git/how_to_fork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/git/pic_git/how_to_fork.png -------------------------------------------------------------------------------- /6_tools/latex/src/My_xelatex/missfont.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/latex/src/My_xelatex/missfont.log -------------------------------------------------------------------------------- /6_tools/latex/src/My_xelatex/nwpuname.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/latex/src/My_xelatex/nwpuname.png -------------------------------------------------------------------------------- /6_tools/latex/src/My_xelatex/tmp.aux: -------------------------------------------------------------------------------- 1 | \relax 2 | \providecommand {\FN@pp@footnotehinttrue }{} 3 | \providecommand {\FN@pp@footnote@aux }[2]{} 4 | \@writefile{toc}{\contentsline {section}{\numberline {第一章}绪论}{1}} 5 | \@writefile{toc}{\contentsline {section}{\numberline {第二章}编队控制}{2}} 6 | \FN@pp@footnotehinttrue 7 | -------------------------------------------------------------------------------- /6_tools/latex/src/My_xelatex/tmp.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/latex/src/My_xelatex/tmp.pdf -------------------------------------------------------------------------------- /6_tools/latex/src/My_xelatex/tmp.synctex.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/latex/src/My_xelatex/tmp.synctex.gz -------------------------------------------------------------------------------- /6_tools/latex/src/My_xelatex/tmp.toc: -------------------------------------------------------------------------------- 1 | \contentsline {section}{\numberline {第一章}绪论}{1} 2 | \contentsline {section}{\numberline {第二章}编队控制}{2} 3 | -------------------------------------------------------------------------------- /6_tools/latex/src/hello_world/document.aux: -------------------------------------------------------------------------------- 1 | \relax 2 | \@writefile{toc}{\contentsline {section}{\numberline {1}你好中国}{1}} 3 | \@writefile{toc}{\contentsline {subsection}{\numberline {1.1}Hello Beijing}{1}} 4 | \@writefile{toc}{\contentsline {subsubsection}{\numberline {1.1.1}Hello Dongcheng District}{1}} 5 | \@writefile{toc}{\contentsline {paragraph}{Tian'anmen Square}{1}} 6 | \@writefile{toc}{\contentsline {subparagraph}{Chairman Mao}{1}} 7 | \@writefile{toc}{\contentsline {subsection}{\numberline {1.2}Hello 北京}{1}} 8 | \@writefile{toc}{\contentsline {paragraph}{北京}{1}} 9 | -------------------------------------------------------------------------------- /6_tools/latex/src/hello_world/document.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/latex/src/hello_world/document.pdf -------------------------------------------------------------------------------- /6_tools/latex/src/hello_world/document.synctex.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/latex/src/hello_world/document.synctex.gz -------------------------------------------------------------------------------- /6_tools/latex/src/hello_world/document.tex: -------------------------------------------------------------------------------- 1 | \documentclass[UTF8]{ctexart} 2 | \title{你好,world!} 3 | \author{Xsc} 4 | \date{\today} 5 | \begin{document} 6 | \maketitle 7 | \tableofcontents 8 | \section{你好中国} 9 | 中国在 East Asia. 10 | \subsection{Hello Beijing} 11 | 北京是 capital of China. 12 | \subsubsection{Hello Dongcheng District} 13 | \paragraph{Tian'anmen Square} 14 | is in the center of Beijing 15 | \subparagraph{Chairman Mao} 16 | is in the center of 天安门广场。 17 | \subsection{Hello 北京} 18 | \paragraph{北京} is an international city。 19 | \end{document} -------------------------------------------------------------------------------- /6_tools/latex/src/hello_world/document.toc: -------------------------------------------------------------------------------- 1 | \contentsline {section}{\numberline {1}你好中国}{1} 2 | \contentsline {subsection}{\numberline {1.1}Hello Beijing}{1} 3 | \contentsline {subsubsection}{\numberline {1.1.1}Hello Dongcheng District}{1} 4 | \contentsline {paragraph}{Tian'anmen Square}{1} 5 | \contentsline {subparagraph}{Chairman Mao}{1} 6 | \contentsline {subsection}{\numberline {1.2}Hello 北京}{1} 7 | \contentsline {paragraph}{北京}{1} 8 | -------------------------------------------------------------------------------- /6_tools/linux/docs/Bash-Beginners-Guide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/linux/docs/Bash-Beginners-Guide.pdf -------------------------------------------------------------------------------- /6_tools/linux/docs/Linux_Complete_Command_Line.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/linux/docs/Linux_Complete_Command_Line.pdf -------------------------------------------------------------------------------- /6_tools/linux/docs/bashref.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/linux/docs/bashref.pdf -------------------------------------------------------------------------------- /6_tools/linux/docs/scripts/StartWork.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## open target terminal 4 | t2(){ 5 | xfce4-terminal --working-directory=/home/pilab/xsc/2_learnSpace/3_machineLearning 6 | } 7 | 8 | ## open terminal in ~ 9 | t3(){ 10 | xfce4-terminal 11 | } 12 | ## open useful file, folder && open browser && vscode workspace && mount remote server 13 | t4(){ 14 | xfce4-terminal -e "typora /home/pilab/xsc/2_learnSpace/0_learn_program_git/6_tools/linux/learn_bash.md" --tab -e "typora /home/pilab/xsc/1_workSpace/workPad.md" --tab -e "firefox" --tab -e "/usr/share/code/code /home/pilab/xsc/2_learnSpace/" --tab -e "echo 'pilab' | sudo -S mount -t nfs 192.168.1.4:/home/a409 /home/a409" --tab -e "pcmanfm /home/pilab/xsc/2_learnSpace/3_machineLearning" 15 | } 16 | 17 | ## check on autoStart working 18 | t5(){ 19 | xfce4-terminal -H -e " echo 'AutoStart finished, enjoy your work day.'" 20 | } 21 | 22 | (t1 &) 23 | (t2 &) 24 | (t3 &) 25 | (t4 &) 26 | (t5 &) 27 | 28 | ''' 29 | for cmd in "$@": do 30 | ($cmd) 31 | ''' 32 | exit 0 33 | -------------------------------------------------------------------------------- /6_tools/linux/docs/scripts/demo_lml_starter.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Main: used to tune system audio output and load vlc music library 4 | # Requirement: 5 | # Audio controller: pulseAudiol, ALSA 6 | # Music player:VLC 7 | 8 | HERE="$(dirname "$(readlink -f "${0}")")" 9 | LML_LB="~/xsc/3_materials/local_music_library" 10 | 11 | temp_cn=$#. 12 | 13 | 14 | 15 | if [ $1 ];then 16 | cho_LB=$1 17 | else 18 | cho_LB='' 19 | fi 20 | if [ $2 ];then 21 | playMode=$2 22 | else 23 | playMode='' 24 | fi 25 | 26 | ## set headphone as output with pulse audio 27 | :<&1` 30 | HDAname=${HDAname_arr#*<} 31 | HDAname=${HDAname%%>*} 32 | 33 | echo ${HDAname} 34 | EOF 35 | 36 | # set HDMI card off(not to occupy output line) 37 | pacmd set-card-profile alsa_card.pci-0000_04_00.1 off 38 | # set built-in audio card on with stereo output 39 | pacmd set-card-profile alsa_card.pci-0000_00_1b.0 output:analog-stereo 40 | 41 | # set output to be analog output of HDA 42 | pacmd set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo 43 | 44 | # set output to be headphones of HDA 45 | pacmd set-sink-port alsa_output.pci-0000_00_1b.0.analog-stereo analog-output-headphones 46 | 47 | # set volume to be 35% with ALSA 48 | amixer -D pulse sset Master 35% 49 | 50 | ## add lml files based on VLC 51 | ## Remained 52 | 53 | if [ ${cho_LB} == "favorite"]; then 54 | echo "load favorite library" 55 | elif [${cho_LB} == "all"]; then 56 | echo "load all songs" 57 | else 58 | echo "load default library" 59 | vlc 60 | fi 61 | 62 | -------------------------------------------------------------------------------- /6_tools/linux/docs/ubuntu命令行简明教程.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/linux/docs/ubuntu命令行简明教程.pdf -------------------------------------------------------------------------------- /6_tools/linux/docs/unixtoolbox.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/linux/docs/unixtoolbox.pdf -------------------------------------------------------------------------------- /6_tools/linux/docs/unixtoolbox_cn.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/linux/docs/unixtoolbox_cn.pdf -------------------------------------------------------------------------------- /6_tools/linux/docs/鸟哥的Linux私房菜基础篇-第三版.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/linux/docs/鸟哥的Linux私房菜基础篇-第三版.pdf -------------------------------------------------------------------------------- /6_tools/linux/images/LinuxMint_Software_Source1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/linux/images/LinuxMint_Software_Source1.png -------------------------------------------------------------------------------- /6_tools/linux/images/LinuxMint_Software_Source2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/linux/images/LinuxMint_Software_Source2.png -------------------------------------------------------------------------------- /6_tools/linux/images/man_ls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/linux/images/man_ls.png -------------------------------------------------------------------------------- /6_tools/markdown/README_排版效果.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/markdown/README_排版效果.pdf -------------------------------------------------------------------------------- /6_tools/markdown/class/pictures/an255.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/markdown/class/pictures/an255.jpeg -------------------------------------------------------------------------------- /6_tools/markdown/class/pictures/dashixiong.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/markdown/class/pictures/dashixiong.jpg -------------------------------------------------------------------------------- /6_tools/markdown/class/pictures/kpln.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/markdown/class/pictures/kpln.jpg -------------------------------------------------------------------------------- /6_tools/markdown/class/pictures/markdown 即时渲染.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/markdown/class/pictures/markdown 即时渲染.gif -------------------------------------------------------------------------------- /6_tools/markdown/class/pictures/typora.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/markdown/class/pictures/typora.png -------------------------------------------------------------------------------- /6_tools/markdown/class/pictures/图形环境下 IDE 总揽.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/markdown/class/pictures/图形环境下 IDE 总揽.png -------------------------------------------------------------------------------- /6_tools/markdown/class/pictures/穿vim的小孩.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/markdown/class/pictures/穿vim的小孩.jpg -------------------------------------------------------------------------------- /6_tools/markdown/docs/Markdown 语法手册.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/markdown/docs/Markdown 语法手册.pdf -------------------------------------------------------------------------------- /6_tools/markdown/practice/pics/dcircuit_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/markdown/practice/pics/dcircuit_1.png -------------------------------------------------------------------------------- /6_tools/markdown/practice/pics/dcircuit_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/markdown/practice/pics/dcircuit_2.png -------------------------------------------------------------------------------- /6_tools/markdown/practice/pics/excircuit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/markdown/practice/pics/excircuit.png -------------------------------------------------------------------------------- /6_tools/qt/README.md: -------------------------------------------------------------------------------- 1 | # Qt说明 2 | 3 | ## 1. 安装Qt 4 | 5 | ### 1.1 Windows下安装 6 | Step1: 下载Qt的安装文件,下载地址是: 7 | * http://mirrors.sjtug.sjtu.edu.cn/qt/archive/qt/5.9/5.9.9/qt-opensource-windows-x86-5.9.9.exe 8 | * https://mirrors.tuna.tsinghua.edu.cn/qt/archive/qt/5.9/5.9.9/qt-opensource-windows-x86-5.9.9.exe 9 | * http://mirrors.ustc.edu.cn/qtproject/archive/qt/5.9/5.9.9/qt-opensource-windows-x86-5.9.9.exe 10 | 11 | Step2:下载完成之后,运行安装程序 12 | 13 | Step3:需要注册一个Qt的账号,并利用邮箱验证一下账号 14 | 15 | Step4:选择安装组件:选择`Qt 5.9.9 - MingGW 5.3.0 32bit` 和 `Development and Designer Tools - MingGW 5.3.0 32-bit` ,如下图所示: 16 | ![qt_win_select_components](images/qt_win_select_components.png) 17 | 18 | 19 | 20 | ### 1.2 Linux下安装 21 | 22 | 如果是Ubuntu系统,执行如下命令: 23 | 24 | Qt5安装 25 | ```bash 26 | sudo apt install build-essential cmake git gcc g++ 27 | sudo apt install qt5-default qt5-qmake-bin 28 | sudo apt install libqt5network5 libqt5sql5 libqt5svg5 libqt5svg5-dev 29 | ``` 30 | 31 | Qt4安装 32 | ```bash 33 | sudo apt-get install libqt4-dev libqt4-opengl-dev 34 | ``` 35 | 36 | 37 | ## 2. 示例代码 38 | 39 | * [Qt示例代码](https://gitee.com/pi-lab/code_cook/tree/master/gui/qt) 40 | * [综合示例项目](https://gitee.com/pi-lab/code_cook/blob/master/DemoProjects.md) 41 | 42 | ## 3. 学习资料 43 | * [《Qt学习资料汇总》](https://gitee.com/pi-lab/code_cook/blob/master/gui/qt/README.md) -------------------------------------------------------------------------------- /6_tools/qt/images/qt_win_select_components.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/6_tools/qt/images/qt_win_select_components.png -------------------------------------------------------------------------------- /7_adv_c++/README.md: -------------------------------------------------------------------------------- 1 | # Stage 7 - 现代C++ 2 | 3 | 主要学习C++ 11, C++14, C++20等最新功能、函数。 4 | 5 | 6 | 7 | ## 学习的思路 8 | 9 | 1. 学习C++11的基本用法,可以使用《现代C++教程》或者《Effective C++》 10 | 2. 使用[Svar](https://gitee.com/pi-lab/Svar),并琢磨其中所使用的高级C++技巧 11 | 3. 学习G2O,Ceres等库中高级的C++技巧 12 | 4. 通过编写SLAM程序深刻体会C++高级用法的特性、用处 13 | 14 | 15 | 16 | ## References 17 | 18 | 教程、说明: 19 | 20 | * [C++11 教程](https://gitee.com/pi-lab/SummerCamp/blob/master/cpp/cpp11/c++11.md) 21 | * [Learn Programming - Stage 7 现代C++](https://gitee.com/pi-lab/learn_programming/tree/master/7_adv_c++) 22 | * [C++11 示例代码](https://gitee.com/pi-lab/code_cook/tree/master/c++/c++_basic_stl) 23 | * [C++11常用特性的使用经验总结](https://www.cnblogs.com/feng-sc/p/5710724.html) 24 | 25 | 26 | 27 | 图书: 28 | 29 | * [《现代C++教程(中文版)》.pdf](books/《现代C++教程(中文版)》.pdf) 30 | * [《现代C++教程(英文版)》.pdf](books/《现代C++教程(英文版)》.pdf) 31 | * 《Effective C++》 32 | 33 | -------------------------------------------------------------------------------- /7_adv_c++/books/《现代C++教程(中文版)》.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/7_adv_c++/books/《现代C++教程(中文版)》.pdf -------------------------------------------------------------------------------- /7_adv_c++/books/《现代C++教程(英文版)》.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/7_adv_c++/books/《现代C++教程(英文版)》.pdf -------------------------------------------------------------------------------- /8_other/Compiler.md: -------------------------------------------------------------------------------- 1 | # 编译原理 2 | 3 | 4 | 5 | 理解编译器内部原理,可以让你更高效利用它。按照编译的工作顺序,逐步深入编程语言和编译器是怎样工作的。本文有大量的链接、样例代码和图表帮助你理解编译器。 6 | 7 | ![compiler](images/compiler.jpg) 8 | 9 | * [编译原理入门笔记](https://zhuanlan.zhihu.com/p/130702001) 10 | * [编译原理入门篇](https://www.cnblogs.com/fisherss/p/13905395.html) 11 | * [人人都能读懂的编译器原理](https://zhuanlan.zhihu.com/p/53336801) 12 | 13 | 14 | 15 | ## GCC 工具链 16 | 17 | * gcc / g++ 18 | 19 | * 静态库 20 | 21 | * 动态库 22 | 23 | * ldd 24 | 25 | * nm 26 | 27 | * readelf 28 | 29 | 30 | -------------------------------------------------------------------------------- /8_other/ComputerArch_EmbeddedSystem.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/8_other/ComputerArch_EmbeddedSystem.md -------------------------------------------------------------------------------- /8_other/Network.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/8_other/Network.md -------------------------------------------------------------------------------- /8_other/OperatingSystem.md: -------------------------------------------------------------------------------- 1 | # 操作系统入门 2 | 3 | 计算的操作系统对于计算机十分重要,从使用者角度来说,操作系统可以对计算机系统的各项资源板块开展调度工作,其中包括软硬件设备、数据信息等,运用计算机操作系统可以减少人工资源分配的工作强度,使用者对于计算的操作干预程度减少,计算机的智能化工作效率就可以得到很大的提升。其次在资源管理方面,如果由多个用户共同来管理一个计算机系统,那么可能就会有冲突矛盾存在于两个使用者的信息共享当中。为了更加合理的分配计算机的各个资源板块,协调计算机系统的各个组成部分,就需要充分发挥计算机操作系统的职能,对各个资源板块的使用效率和使用程度进行一个最优的调整,使得各个用户的需求都能够得到满足。最后,操作系统在计算机程序的辅助下,可以抽象处理计算系统资源提供的各项基础职能,以可视化的手段来向使用者展示操作系统功能,减低计算机的使用难度。 4 | 5 | 开发高级的计算机视觉、机器学习应用,需要理解操作系统中进程、文件、设备管理等概念、实现、应用等。非计算机专业的同学并没有学过此课程,因此大家可以通过如下的网上资料快速入手并学会基本的知识,并在后续学习过程不断深入对操作系统的理解。 6 | 7 | * [计算机操作系统知识点总结](https://blog.csdn.net/Royalic/article/details/119999404) 8 | * [Linux入门教程](http://c.biancheng.net/linux_tutorial/) 9 | 10 | -------------------------------------------------------------------------------- /8_other/images/compiler.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/8_other/images/compiler.jpg -------------------------------------------------------------------------------- /Progress.md: -------------------------------------------------------------------------------- 1 | # 进度与建议 2 | 3 | 4 | 5 | ## 1. 进度 6 | 7 | ### 2022年6月17日 (示例) 8 | 9 | 1. 学习并练习了树的基本操作,如创建、插入(二叉查找树的递归和循环插入)、遍历(前中后序的递归和循环、层序遍历实现)、树的翻转算法。有关树的操作,尤其是涉及需要遍历树的操作,递归用的很多,通过这个过程掌握了递归的用法。 10 | 2. `leetcode`做题,在`3_code_practice`的`README`文档中建立表格索引,将所练习的题目的信息以及解题心得和尚待改进的地方做个标记,方便检索和日后将程序进行优化。 11 | 3. 建立`fatal error informations and solutions `文档,做题过程中将所遇到的错误记录下来,并将改进的方法和以后需要注意的点写成文档,以便日后遇到问题有更快的反应,写程序时尽量规避,一次成功。 12 | 13 | 14 | 15 | ## 2. 建议 16 | 17 | -------------------------------------------------------------------------------- /Target.md: -------------------------------------------------------------------------------- 1 | # 需要达到的水平 2 | 3 | 通过一步一步拓展自己的能力范围,逐步达到下述的能力。大家需要思考如何达到下面所列的能力,如何有效评估自己的能力是否达到? 4 | 5 | 6 | ## 1. 编程基础、C++语言 7 | * [ ] C/C++的基本语法 8 | * [ ] 基本类型、基本的语句 9 | * [ ] 函数 10 | * [ ] 指针 11 | * [ ] 结构体 12 | * [ ] 类 13 | * [ ] 模板 14 | * [ ] 宏 15 | 16 | ## 2. 数据结构算法 17 | * [ ] 理解链表、树、图等数据结构 18 | * [ ] 红黑树、图的遍历 19 | * [ ] 各类算法 20 | * [ ] 查找,排序 21 | * [ ] 动态规划、贪心算法 22 | 23 | 24 | ## 3. 工具 25 | * [ ] 能否熟练使用`Git`管理代码、文档 26 | * [ ] 能否使用`Markdown`来编写文档 27 | * [ ] 是否会用`QtCreator`等IDE编写代码,单步调试程序 28 | * [ ] 使用Linux完成程序的编译、安装(安装Linux,Linux常用的命令) 29 | * [ ] 使用Makefile或者CMake编写项目编译脚本等 30 | 31 | 32 | ## 4. 第三方库,Qt,OpenGL等 33 | * [ ] 使用Qt编写简单的界面和可视化程序 34 | * [ ] 使用OpenGL完成三维绘图 35 | * [ ] 使用OpenCV完成图像处理、计算机视觉任务 36 | * [ ] Linux完成程序的编译、安装(安装Linux,Linux常用的命令) 37 | 38 | 39 | ## 5. 项目设计、管理 40 | * [ ] 是否能够将所编写的程序架构设计出来 41 | * [ ] 能否设计程序的模块、类、函数等 42 | * [ ] 各个模块的接口设计 43 | * [ ] [代码规范](5_advanced/programming_standard) 44 | * [ ] [设计模式](5_advanced/4_DesignPattern_UML) 45 | 46 | 47 | ## 6. 思维、方法论 48 | * [ ] 如何分析问题,梳理项目的整体内容、计算点 49 | * [ ] 分析出关键的技术点 50 | * [ ] 如何去找相关资料 51 | 52 | -------------------------------------------------------------------------------- /demo_code/README.md: -------------------------------------------------------------------------------- 1 | ## 编程示例 2 | 3 | 通过学习[【示例程序、项目】](https://gitee.com/pi-lab/code_cook/blob/master/DemoProjects.md),能够学习如何设计程序架构,如何将复杂的功能拆解成小的功能模块等等。 4 | 5 | 通过程序示例可以学习如下的内容: 6 | 1. 编程规范 7 | 2. 命名规范 8 | 3. 程序的组织 9 | 4. 算法及其实现 10 | 5. CMake或者QMake组织程序的代码 11 | 12 | 13 | -------------------------------------------------------------------------------- /images/learn_programming.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/images/learn_programming.png -------------------------------------------------------------------------------- /images/study-methods.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/images/study-methods.pptx -------------------------------------------------------------------------------- /images/suggested_progress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bushuhui/learn_programming/f95d8528844071b2b8f21ba98bd63c2ec3393ba7/images/suggested_progress.png --------------------------------------------------------------------------------