1515// Id creation
1616// ////////////////////////////////////////////////////////////
1717
18- Id::Id ()
19- // : id_( 0 ), index_( 0 )
20- : id_( 0 )
18+ Id::Id () : id_(0 )
2119{
2220 ;
2321}
2422
25- Id::Id ( unsigned int id )
26- : id_( id )
23+ Id::Id (unsigned int id) : id_(id)
2724{
2825 ;
2926}
3027
31- Id::Id ( const string& path, const string& separator )
28+ Id::Id (const string& path, const string& separator)
3229{
33- Shell* shell = reinterpret_cast < Shell* >( Id ().eref ().data () );
34- assert ( shell );
35- id_ = shell->doFind ( path ).id .id_ ;
30+ Shell* shell = reinterpret_cast <Shell*>( Id ().eref ().data ());
31+ assert (shell);
32+ id_ = shell->doFind (path).id .id_ ;
3633}
3734
38- Id::Id ( const ObjId& oi )
39- : id_( oi.id.id_ )
35+ Id::Id (const ObjId& oi) : id_(oi.id.id_)
4036{
4137 ;
4238}
@@ -46,19 +42,19 @@ Id::Id( const ObjId& oi )
4642 * out of the existing range, but it would be nice to have a heuristic
4743 * on how outrageous the incoming value is.
4844 */
49- Id Id::str2Id ( const std::string& s )
45+ Id Id::str2Id (const std::string& s)
5046{
5147 // unsigned int val = atoi( s.c_str() );
52- return Id ( s );
48+ return Id (s );
5349}
5450
5551// ////////////////////////////////////////////////////////////
5652// Element array static access function. Private.
5753// ////////////////////////////////////////////////////////////
5854
59- vector< Element* >& Id::elements ()
55+ vector<Element*>& Id::elements ()
6056{
61- static vector< Element* > e;
57+ static vector<Element*> e;
6258 return e;
6359}
6460
@@ -67,31 +63,29 @@ vector< Element* >& Id::elements()
6763// ////////////////////////////////////////////////////////////
6864
6965// static func to convert id into a string.
70- string Id::id2str ( Id id )
66+ string Id::id2str (Id id)
7167{
7268 return id.path ();
7369}
7470
7571// Function to convert it into its fully separated path.
76- string Id::path ( const string& separator) const
72+ string Id::path (const string& separator) const
7773{
78- string ret = Neutral::path ( eref () );
74+ string ret = Neutral::path (eref ());
7975
8076 // FIXME: Monday 09 March 2020 12:30:27 PM IST, Dilawar Singh
81- // This beaks the path comparison. Getting x.path from x returned in a
77+ // This beaks the path comparison. Getting x.path from x returned in a
8278 // list by moose.wildcardFind() and getting path from here doesn't math
8379 // when this is enabled.
8480 // If we want to remove [0] then it should be done globally and not just
8581 // here.
8682
87- // Trim off trailing []
88- assert ( ret.length () > 0 );
89- while ( ret.back () == ' ]' )
90- {
91- size_t pos = ret.find_last_of ( ' [' );
92- if ( pos != string::npos && pos > 0 )
93- {
94- ret = ret.substr ( 0 , pos );
83+ // Trim off trailing []
84+ assert (ret.length () > 0 );
85+ while (ret.back () == ' ]' ) {
86+ size_t pos = ret.find_last_of (' [' );
87+ if (pos != string::npos && pos > 0 ) {
88+ ret = ret.substr (0 , pos);
9589 }
9690 }
9791
@@ -111,26 +105,26 @@ string Id::path( const string& separator) const
111105 * deprecated
112106Element* Id::operator()() const
113107{
114- return elements()[ id_ ];
108+ return elements()[ id_ ];
115109}
116110 */
117111
118112// / Synonym for Id::operator()()
119113Element* Id::element () const
120114{
121- return elements ()[ id_ ];
115+ return elements ()[id_];
122116}
123117
124118/*
125119unsigned int Id::index() const
126120{
127- return index_;
121+ return index_;
128122}
129123*/
130124
131125Eref Id::eref () const
132126{
133- return Eref ( elements ()[ id_ ], 0 );
127+ return Eref (elements ()[id_], 0 );
134128 // return Eref( elements()[ id_ ], index_ );
135129}
136130
@@ -140,8 +134,8 @@ Id Id::nextId()
140134 // Should really look up 'available' list.
141135 // Should really put the returned value onto the 'reserved' list
142136 // so they don't go dangling.
143- Id ret ( elements ().size () );
144- elements ().push_back ( 0 );
137+ Id ret (elements ().size ());
138+ elements ().push_back (0 );
145139 return ret;
146140}
147141
@@ -151,53 +145,49 @@ unsigned int Id::numIds()
151145 return elements ().size ();
152146}
153147
154- void Id::bindIdToElement ( Element* e )
148+ void Id::bindIdToElement (Element* e)
155149{
156- if ( elements ().size () <= id_ )
157- {
158- if ( elements ().size () % 1000 == 0 )
159- {
160- elements ().reserve ( elements ().size () + 1000 );
150+ if (elements ().size () <= id_) {
151+ if (elements ().size () % 1000 == 0 ) {
152+ elements ().reserve (elements ().size () + 1000 );
161153 }
162- elements ().resize ( id_ + 1 , 0 );
154+ elements ().resize (id_ + 1 , 0 );
163155 }
164- assert ( elements ()[ id_ ] == 0 );
156+ assert (elements ()[id_] == 0 );
165157 /*
166158 if ( elements()[ id_ ] != 0 )
167- cout << "Warning: assigning Element to existing id " << id_ << "\n";
168- */
169- elements ()[ id_ ] = e;
159+ cout << "Warning: assigning Element to existing id " << id_ << "\n";
160+ */
161+ elements ()[id_] = e;
170162 // cout << "Id::bindIdToElement '" << e->getName() << "' = " << id_ << endl;
171163}
172164
173165/*
174166Id Id::create( Element* e )
175167{
176- Id ret( elements().size() );
177- elements().push_back( e );
178- return ret;
168+ Id ret( elements().size() );
169+ elements().push_back( e );
170+ return ret;
179171}
180172*/
181173
182174void Id::destroy () const
183175{
184- if ( elements ()[ id_ ] )
185- {
186- // cout << "Id::destroy '" << elements()[ id_ ]->getName() << "' = " << id_ << endl;
187- delete elements ()[ id_ ];
188- elements ()[ id_ ] = 0 ;
176+ if (elements ()[id_]) {
177+ // cout << "Id::destroy '" << elements()[ id_ ]->getName() << "' = " <<
178+ // id_ << endl;
179+ delete elements ()[id_];
180+ elements ()[id_] = 0 ;
189181 // Put id_ on 'available' list
190- }
191- else
192- {
182+ } else {
193183 cout << " Warning: Id::destroy: " << id_ << " already zeroed\n " ;
194184 }
195185}
196186
197187void Id::zeroOut () const
198188{
199- assert ( id_ < elements ().size () );
200- elements ()[ id_ ] = 0 ;
189+ assert ( id_ < elements ().size ());
190+ elements ()[id_] = 0 ;
201191}
202192
203193unsigned int Id::value () const
@@ -207,11 +197,9 @@ unsigned int Id::value() const
207197
208198void Id::clearAllElements ()
209199{
210- for ( vector< Element* >::iterator
211- i = elements ().begin (); i != elements ().end (); ++i )
212- {
213- if ( *i )
214- {
200+ for (vector<Element*>::iterator i = elements ().begin ();
201+ i != elements ().end (); ++i) {
202+ if (*i) {
215203 (*i)->clearAllMsgs ();
216204 delete *i;
217205 }
@@ -222,28 +210,28 @@ void Id::clearAllElements()
222210// Id utility
223211// ////////////////////////////////////////////////////////////
224212
225- ostream& operator <<( ostream& s, const Id& i )
213+ ostream& operator <<(ostream& s, const Id& i)
226214{
227215 s << i.id_ ;
228216 /*
229217 if ( i.index_ == 0 )
230- s << i.id_;
218+ s << i.id_;
231219 else
232- s << i.id_ << "[" << i.index_ << "]";
220+ s << i.id_ << "[" << i.index_ << "]";
233221 */
234222 return s;
235223}
236224
237- istream& operator >>( istream& s, Id& i )
225+ istream& operator >>(istream& s, Id& i)
238226{
239227 s >> i.id_ ;
240228 return s;
241229}
242230
243231/*
244232Id::Id( unsigned int id, unsigned int index )
245- : id_( id ), index_( index )
233+ : id_( id ), index_( index )
246234{
247- ;
235+ ;
248236}
249237*/
0 commit comments