OpenWalnut  1.2.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
WItemSelection.cpp
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #include <string>
26 #include <vector>
27 
28 #include "WLogger.h"
29 
30 #include "exceptions/WOutOfBounds.h"
31 #include "exceptions/WNameNotUnique.h"
32 #include "WItemSelector.h"
33 
34 #include "WItemSelection.h"
35 
37  WSharedSequenceContainer< std::vector< boost::shared_ptr< WItemSelectionItem > > >()
38 {
39  // initialize members
40 }
41 
43 {
44  // cleanup
45 }
46 
48 {
51 
52  for( size_t i = 0; i < r->get().size(); ++i )
53  {
54  l.push_back( i );
55  }
56  return WItemSelector( shared_from_this(), l );
57 }
58 
60 {
63  return WItemSelector( shared_from_this(), l );
64 }
65 
67 {
70 
71  if( r->get().size() >= 1 )
72  {
73  l.push_back( 0 );
74  }
75  return WItemSelector( shared_from_this(), l );
76 }
77 
79 {
82 
83  if( r->get().size() >= 1 )
84  {
85  l.push_back( r->get().size() - 1 );
86  }
87  return WItemSelector( shared_from_this(), l );
88 }
89 
91 {
94 
95  if( r->get().size() <= item )
96  {
97  throw WOutOfBounds( std::string( "The specified item does not exist." ) );
98  }
99  l.push_back( item );
100  return WItemSelector( shared_from_this(), l );
101 }
102 
103 void WItemSelection::addItem( std::string name, std::string description, const char** icon )
104 {
105  push_back( boost::shared_ptr< WItemSelectionItem >( new WItemSelectionItem( name, description, icon ) ) );
106 }
107