1 // ======================================================================
3 // UIBuilderHistory.cpp
4 // copyright (c) 2001 Sony Online Entertainment
6 // ======================================================================
8 #include "FirstUiBuilder.h"
9 #include "UIBuilderHistory.h"
13 //-----------------------------------------------------------------
16 typedef std::vector
<std::string
> HistoryVector
;
17 HistoryVector
* ms_history
;
21 //-----------------------------------------------------------------
23 void UIBuilderHistory::install ()
25 assert (!ms_installed
);
26 ms_history
= new HistoryVector
;
31 //-----------------------------------------------------------------
33 void UIBuilderHistory::remove ()
35 assert (ms_installed
);
41 //-----------------------------------------------------------------
43 bool UIBuilderHistory::back (std::string
& path
)
48 path
= (*ms_history
) [--ms_index
];
53 //-----------------------------------------------------------------
55 bool UIBuilderHistory::forward (std::string
& path
)
60 path
= (*ms_history
) [++ms_index
];
64 //-----------------------------------------------------------------
66 void UIBuilderHistory::pushNode (const std::string
& path
)
68 assert (ms_installed
);
69 if (!ms_history
->empty () && ms_index
< ms_history
->size () - 1)
71 HistoryVector::iterator it
= ms_history
->begin ();
72 std::advance (it
, ms_index
+ 1);
73 ms_history
->erase (it
, ms_history
->end ());
76 if (!ms_history
->empty ())
79 ms_history
->push_back (path
);
82 //-----------------------------------------------------------------
84 bool UIBuilderHistory::backValid ()
86 assert (ms_installed
);
87 return (ms_index
> 0);
90 //-----------------------------------------------------------------
92 bool UIBuilderHistory::forwardValid ()
94 assert (ms_installed
);
95 return (ms_index
< ms_history
->size () - 1);
98 //----------------------------------------------------------------------
100 bool UIBuilderHistory::isInstalled()
105 // ======================================================================