openETCS
case study for the European Train Control System developed for the authors dissertation
NonProperty.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010-2011
3  Johannes Feuser <feuser@uni-bremen.de>
4  This file is part of the openETCS library.
5 
6  The openETCS library is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  any later version.
10 
11  The openETCS library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with the openETCS library. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 /*!
21  * \author Johannes Feuser <feuser@uni-bremen.de>
22  * \brief
23  */
24 
25 #include "NonProperty.h"
26 #include "Property.h"
27 
28 
29 namespace GOPPRR {
30 
31 
32 CNonProperty::CNonProperty(const ::std::string& OID, const ::std::string& Type, const ::std::string& ID, const std::map< ::std::string, ::GOPPRR::CProperty* >& Properties) throw()
33 :CConcept(OID, Type),
34  m_ID(ID),
35  m_Properties(Properties)
36 {
37  // Bouml preserved body begin 00026502
38  // empty constructor
39  // Bouml preserved body end 00026502
40 
41 } // CNonProperty::CNonProperty() throw()
42 
43 
44 
45 
47 :CConcept(Source),
48  m_ID(Source.m_ID),
49  m_Properties(Source.m_Properties)
50 {
51  // Bouml preserved body begin 00026602
52  // empty copy constructor
53  // Bouml preserved body end 00026602
54 
55 } // CNonProperty::CNonProperty() throw()
56 
57 
58 
59 
61 {
62  // Bouml preserved body begin 00026582
63  // empty destructor
64  // Bouml preserved body end 00026582
65 
66 } // CNonProperty::~CNonProperty() throw()
67 
68 
69 
70 
72 {
73  // Bouml preserved body begin 00048A02
74  // assign member values from source
75  m_ID = Source.m_ID;
76  m_Properties = Source.m_Properties;
77 
78  // call operator of base class
79  ::GOPPRR::CConcept::operator =(Source);
80 
81  // return reference to this instance
82  return (*this);
83  // Bouml preserved body end 00048A02
84 
85 } // GOPPRR::CNonProperty CNonProperty::operator=() throw()
86 
87 
88 
89 
90 ::std::map< ::std::string, GOPPRR::CProperty* > CNonProperty::Properties(const ::std::string& Type, const bool& bSubString, const bool& bUseException) const throw(::GOPPRR::Error::CEmpty)
91 {
92  // Bouml preserved body begin 000A3702
93  ::std::map< ::std::string, ::GOPPRR::CProperty* >::const_iterator Property;
94  ::std::map< ::std::string, ::GOPPRR::CProperty* > Properties;
95 
96 
97 
98  // process all properties of this instance
99  for (Property = this->m_Properties.begin(); Property != this->m_Properties.end(); Property++)
100  {
101  // check, if current type of property is searched one
102  if ((!bSubString && Property->second->m_Type == Type) || (bSubString && Property->second->m_Type.find(Type) != ::std::string::npos))
103  {
104  // add property to map
105  Properties[ Property->second->m_OID ] = Property->second;
106 
107  } // if ((!bSubString && Property->second->m_Type == Type) || (bSubString && Property->second->m_Type.find(Type) != ::std::string::npos))
108 
109  } // for (Property = this->m_Properties.begin(); Property != this->m_Properties.end(); Property++)
110 
111  // check, if exception should be used and map is empty
112  if (bUseException && Properties.empty())
113  {
114  // construct and throw exception
115  throw (::GOPPRR::Error::CEmpty("no property of type \"" + Type + "\" found"));
116 
117  } // if (bUseException && Properties.empty())
118 
119  // return map of found properties
120  return (Properties);
121  // Bouml preserved body end 000A3702
122 
123 } // GOPPRR::CProperty CNonProperty::Properties() const throw(::GOPPRR::Error::CEmpty)
124 
125 
126 
127 
128 
129 
130 } // namespace GOPPRR

Copyright (C) 2010-2012 Johannes Feuser (feuser@uni-bremen.de)
The openETCS library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
The openETCS library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the openETCS library. If not, see "http://www.gnu.org/licenses/.