1616// ////////////////////////////////////////////////////////////
1717
1818Id::Id ()
19- // : id_( 0 ), index_( 0 )
20- : id_( 0 )
19+ // : id_( 0 ), index_( 0 )
20+ : id_(0 )
2121{
2222 ;
2323}
2424
25- Id::Id ( unsigned int id )
26- : id_( id )
25+ Id::Id (unsigned int id) : id_(id)
2726{
2827 ;
2928}
3029
31- Id::Id ( const string& path, const string& separator )
30+ Id::Id (const string& path)
3231{
33- Shell* shell = reinterpret_cast < Shell* >( Id ().eref ().data () );
34- assert ( shell );
35- id_ = shell->doFind ( path ).id .id_ ;
32+ Shell* shell = reinterpret_cast <Shell*>( Id ().eref ().data ());
33+ assert (shell);
34+ id_ = shell->doFind (path).id .id_ ;
3635}
3736
38- Id::Id ( const ObjId& oi )
39- : id_( oi.id.id_ )
37+ Id::Id (const ObjId& oi) : id_(oi.id.id_)
4038{
4139 ;
4240}
@@ -46,19 +44,19 @@ Id::Id( const ObjId& oi )
4644 * out of the existing range, but it would be nice to have a heuristic
4745 * on how outrageous the incoming value is.
4846 */
49- Id Id::str2Id ( const std::string& s )
47+ Id Id::str2Id (const std::string& s)
5048{
5149 // unsigned int val = atoi( s.c_str() );
52- return Id ( s );
50+ return Id (s );
5351}
5452
5553// ////////////////////////////////////////////////////////////
5654// Element array static access function. Private.
5755// ////////////////////////////////////////////////////////////
5856
59- vector< Element* >& Id::elements ()
57+ vector<Element*>& Id::elements ()
6058{
61- static vector< Element* > e;
59+ static vector<Element*> e;
6260 return e;
6361}
6462
@@ -67,31 +65,29 @@ vector< Element* >& Id::elements()
6765// ////////////////////////////////////////////////////////////
6866
6967// static func to convert id into a string.
70- string Id::id2str ( Id id )
68+ string Id::id2str (Id id)
7169{
7270 return id.path ();
7371}
7472
7573// Function to convert it into its fully separated path.
76- string Id::path ( const string& separator ) const
74+ string Id::path () const
7775{
78- string ret = Neutral::path ( eref () );
76+ string ret = Neutral::path (eref ());
7977
8078 // 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
79+ // This beaks the path comparison. Getting x.path from x returned in a
8280 // list by moose.wildcardFind() and getting path from here doesn't math
8381 // when this is enabled.
8482 // If we want to remove [0] then it should be done globally and not just
8583 // here.
8684
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 );
85+ // Trim off trailing []
86+ assert (ret.length () > 0 );
87+ while (ret.back () == ' ]' ) {
88+ size_t pos = ret.find_last_of (' [' );
89+ if (pos != string::npos && pos > 0 ) {
90+ ret = ret.substr (0 , pos);
9591 }
9692 }
9793
@@ -111,26 +107,26 @@ string Id::path( const string& separator) const
111107 * deprecated
112108Element* Id::operator()() const
113109{
114- return elements()[ id_ ];
110+ return elements()[ id_ ];
115111}
116112 */
117113
118114// / Synonym for Id::operator()()
119115Element* Id::element () const
120116{
121- return elements ()[ id_ ];
117+ return elements ()[id_];
122118}
123119
124120/*
125121unsigned int Id::index() const
126122{
127- return index_;
123+ return index_;
128124}
129125*/
130126
131127Eref Id::eref () const
132128{
133- return Eref ( elements ()[ id_ ], 0 );
129+ return Eref (elements ()[id_], 0 );
134130 // return Eref( elements()[ id_ ], index_ );
135131}
136132
@@ -140,8 +136,8 @@ Id Id::nextId()
140136 // Should really look up 'available' list.
141137 // Should really put the returned value onto the 'reserved' list
142138 // so they don't go dangling.
143- Id ret ( elements ().size () );
144- elements ().push_back ( 0 );
139+ Id ret (elements ().size ());
140+ elements ().push_back (0 );
145141 return ret;
146142}
147143
@@ -151,53 +147,49 @@ unsigned int Id::numIds()
151147 return elements ().size ();
152148}
153149
154- void Id::bindIdToElement ( Element* e )
150+ void Id::bindIdToElement (Element* e)
155151{
156- if ( elements ().size () <= id_ )
157- {
158- if ( elements ().size () % 1000 == 0 )
159- {
160- elements ().reserve ( elements ().size () + 1000 );
152+ if (elements ().size () <= id_) {
153+ if (elements ().size () % 1000 == 0 ) {
154+ elements ().reserve (elements ().size () + 1000 );
161155 }
162- elements ().resize ( id_ + 1 , 0 );
156+ elements ().resize (id_ + 1 , 0 );
163157 }
164- assert ( elements ()[ id_ ] == 0 );
158+ assert (elements ()[id_] == 0 );
165159 /*
166160 if ( elements()[ id_ ] != 0 )
167- cout << "Warning: assigning Element to existing id " << id_ << "\n";
168- */
169- elements ()[ id_ ] = e;
161+ cout << "Warning: assigning Element to existing id " << id_ << "\n";
162+ */
163+ elements ()[id_] = e;
170164 // cout << "Id::bindIdToElement '" << e->getName() << "' = " << id_ << endl;
171165}
172166
173167/*
174168Id Id::create( Element* e )
175169{
176- Id ret( elements().size() );
177- elements().push_back( e );
178- return ret;
170+ Id ret( elements().size() );
171+ elements().push_back( e );
172+ return ret;
179173}
180174*/
181175
182176void Id::destroy () const
183177{
184- if ( elements ()[ id_ ] )
185- {
186- // cout << "Id::destroy '" << elements()[ id_ ]->getName() << "' = " << id_ << endl;
187- delete elements ()[ id_ ];
188- elements ()[ id_ ] = 0 ;
178+ if (elements ()[id_]) {
179+ // cout << "Id::destroy '" << elements()[ id_ ]->getName() << "' = " <<
180+ // id_ << endl;
181+ delete elements ()[id_];
182+ elements ()[id_] = 0 ;
189183 // Put id_ on 'available' list
190- }
191- else
192- {
184+ } else {
193185 cout << " Warning: Id::destroy: " << id_ << " already zeroed\n " ;
194186 }
195187}
196188
197189void Id::zeroOut () const
198190{
199- assert ( id_ < elements ().size () );
200- elements ()[ id_ ] = 0 ;
191+ assert ( id_ < elements ().size ());
192+ elements ()[id_] = 0 ;
201193}
202194
203195unsigned int Id::value () const
@@ -207,11 +199,9 @@ unsigned int Id::value() const
207199
208200void Id::clearAllElements ()
209201{
210- for ( vector< Element* >::iterator
211- i = elements ().begin (); i != elements ().end (); ++i )
212- {
213- if ( *i )
214- {
202+ for (vector<Element*>::iterator i = elements ().begin ();
203+ i != elements ().end (); ++i) {
204+ if (*i) {
215205 (*i)->clearAllMsgs ();
216206 delete *i;
217207 }
@@ -222,28 +212,28 @@ void Id::clearAllElements()
222212// Id utility
223213// ////////////////////////////////////////////////////////////
224214
225- ostream& operator <<( ostream& s, const Id& i )
215+ ostream& operator <<(ostream& s, const Id& i)
226216{
227217 s << i.id_ ;
228218 /*
229219 if ( i.index_ == 0 )
230- s << i.id_;
220+ s << i.id_;
231221 else
232- s << i.id_ << "[" << i.index_ << "]";
222+ s << i.id_ << "[" << i.index_ << "]";
233223 */
234224 return s;
235225}
236226
237- istream& operator >>( istream& s, Id& i )
227+ istream& operator >>(istream& s, Id& i)
238228{
239229 s >> i.id_ ;
240230 return s;
241231}
242232
243233/*
244234Id::Id( unsigned int id, unsigned int index )
245- : id_( id ), index_( index )
235+ : id_( id ), index_( index )
246236{
247- ;
237+ ;
248238}
249239*/
0 commit comments