HowTo create a new view ======================= $Id: CreateView.txt,v 1.4 2005/09/05 16:16:29 petan Exp $ Created 2000-09-16 by Fredrik Heintz Last updated 2002-09-13 by Fredrik Heintz The purpose of this HowTo is to describe how to create a new view and add it to the RoboSoc distribution. I will use the DashView view as an example. All paths are relative to the RoboSoc directory. Hint: Copy this file and then search and replace DashView with the name of the view you want to create. Then you can copy the commands from this file without very many changes. -1. Make sure that the template directory is updated. &> cvs update -d Framework/template/ 0. Go to the RoboSoc directory. 1. Copy the files ViewStub.h ViewStub.icc ViewStub.cc from Framework/template to your preferred view location. %> cp Framework/template/ViewStub.* myDir 2. Change the names of the files to the name of the view. %> cd myDir %> mv ViewStub.h DashView.h %> mv ViewStub.icc DashView.icc %> mv ViewStub.cc DashView.cc 3. Open the files and change the names inside. %> emacs DashView.h DashView.icc DashView.cc & C-x b DashView.cc (change buffers to DashView.cc) M-< (goto the top of the file) M-% viewstub DashView (search and replace) ! (replace all instances) C-x b DashView.icc (change buffers to DashView.icc) replace the names as above C-x b DashView.h (change buffers to DashView.h) replace the names as above 4. If the view should use history then it should inherit from ViewWithHistory. C-x b DashView.h (change buffers to DashView.h) C-s #include "View.h" (search for #include "View.h") change it to #include "ViewWithHistory.h" C-s public View (search for public view) change it to public ViewWithHistory C-x b DashView.cc (change buffers to DashView.cc) C-s : View (search for : View) change it to : ViewWithHistory 5. Change the description of the files and the view. C-x b DashView.h (change buffers to DashView.h) C-s Created by (search Created by) change the name and date C-s $Log (search for $Log) remove everything between $Log ...$ and */ C-s @class (search for @class) change the description of the view, its preconditions and postconditions. C-x C-s (save the changes) C-x b DashView.icc (change buffers to DashView.icc) change name, date and remove old log information as above C-x b DashView.cc (change buffers to DashView.cc) change name, date and remove old log information as above 6. Add the view dependecies to the implementation file. C-x b DashView.h (change buffers to DashView.h) C-s protected: (search for protected:) add ViewName* viewName; for each view you want to use C-x b DashView.cc (change buffers to DashView.cc) C-s #include (search for #include) add #include "ViewName.h" to make a dependency C-x C-s (save the changes) Do not forget to update the view you depend on before you use it! Example: To depend on the information from agent view to update after see do: agentView->updateAfterSee(currentUpdateNumber); at the first line of your myUpdateAfterSee() method. 7. If you don't use an inline methods then the .icc file should be empty. If it is, delete it. Also remove the section as instructed at the end of the .h and .cc files. %> rm DashView.icc C-x b DashView.cc (change buffers to DashView.cc) C-s // Remove (search for // Remove) remove the section C-x C-s (save the changes) C-x b DashView.h (change buffers to DashView.h) remove as above 8. Add the files to Makefile.am C-x C-f Makefile.am (open myDir/Makefile.am) add DashView.h and DashView.icc to VIEW_HEADER only DashView.h if no inline methods are used add DashView.cc to VIEW_SOURCE If add the files on a new line don't forget the backslash at the end of the previous line! 9. Try to compile the view %> make (in the myDir directory)