This file is indexed.

/usr/include/libmesh/parameters.h is in libmesh-dev 0.7.1-2ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
// $Id: parameters.h 4279 2011-03-21 17:01:31Z roystgnr $

// The libMesh Finite Element Library.
// Copyright (C) 2002-2008 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
  
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
  
// This 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
// Lesser General Public License for more details.
  
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



#ifndef __parameters_h__
#define __parameters_h__

// C++ includes
#include <typeinfo>
#include <string>
#include <map>

// Local includes
#include "libmesh_common.h"
#include "reference_counted_object.h"

namespace libMesh
{



/**
 * This class provides the ability to map between
 * arbitrary, user-defined strings and several data
 * types.  This can be used to provide arbitrary
 * user-specified options.
 *
 * \author Benjamin S. Kirk
 * \date 2004
 * \version $Revision: 4279 $
 */

// ------------------------------------------------------------
// Parameters class definition
class Parameters 
{
public:

  /**
   * Default constructor.  Does nothing.
   */
  Parameters () {};

  /**
   * Copy constructor.
   */
  Parameters (const Parameters&);

  /**
   * Destructor.  Clears any allocated memory.
   */
  ~Parameters ();

  /**
   * Assignment operator.  Removes all parameters in \p this
   * and inserts copies of all parameters from \p source
   */
  Parameters& operator= (const Parameters& source);

  /**
   * Addition/Assignment operator.  Inserts copies of all parameters
   * from \p source.  Any parameters of the same name already in \p
   * this are replaced.
   */
  Parameters& operator+= (const Parameters& source);

  /**
   * @returns \p true if a parameter of type \p T
   * with a specified name exists, \p false otherwise.
   *
   * If RTTI has been disabled then we return \p true
   * if a parameter of specified name exists regardless of its type.
   */
  template <typename T>
  bool have_parameter (const std::string&) const;

  /**
   * @returns a constant reference to the specified parameter
   * value.  Requires, of course, that the parameter exists.
   */
  template <typename T>
  const T& get (const std::string&) const;

  /**
   * @returns a writeable reference to the specified parameter.
   * This method will create the parameter if it does not exist,
   * so it can be used to define parameters which will later be
   * accessed with the \p get() member.
   */
  template <typename T>
  T& set (const std::string&);

  /**
   * Removes the specified parameter from the list, if it exists.
   */
  void remove (const std::string&);

  /**
   * @returns the total number of parameters.
   */
  unsigned int n_parameters () const { return _values.size(); }

#ifdef LIBMESH_HAVE_RTTI
  /**
   * @returns the number of parameters of the requested type.
   */
  template <typename T>
  unsigned int n_parameters () const;
#endif // LIBMESH_HAVE_RTTI
  
  /**
   * Clears internal data structures & frees any allocated memory.
   */
  void clear ();

  /**
   * Prints the contents, by default to libMesh::out.
   */
  void print (std::ostream& os=libMesh::out) const;
  
private:

  /**
   * Abstract definition of a parameter value.
   */
  class Value : public ReferenceCountedObject<Value>
  {
  public:

    /**
     * Destructor.
     */
    virtual ~Value() {};

#ifdef LIBMESH_HAVE_RTTI
    /**
     * String identifying the type of parameter stored.
     * Must be reimplemented in derived classes.
     */
    virtual std::string type () const = 0;
#endif // LIBMESH_HAVE_RTTI

    /**
     * Prints the parameter value to the specified stream.
     * Must be reimplemented in derived classes.
     */
    virtual void print(std::ostream&) const = 0;

    /**
     * Clone this value.  Useful in copy-construction.
     * Must be reimplemented in derived classes.
     */
    virtual Value* clone () const = 0;
  };

public:

  /**
   * Concrete definition of a parameter value
   * for a specified type.
   */
  template <typename T>
  class Parameter : public Value
  {
  public:

    /**
     * @returns a read-only reference to the parameter value.
     */
    const T& get () const { return _value; }
    
    /**
     * @returns a writeable reference to the parameter value.
     */
    T& set () { return _value; }

#ifdef LIBMESH_HAVE_RTTI
    /**
     * String identifying the type of parameter stored.
     */
    virtual std::string type () const;
#endif // LIBMESH_HAVE_RTTI

    /**
     * Prints the parameter value to the specified stream.
     */
    virtual void print(std::ostream&) const;

    /**
     * Clone this value.  Useful in copy-construction.
     */
    virtual Value* clone () const; 
    
  private:

    /**
     * Stored parameter value.
     */
    T _value;
  };

  /**
   * Parameter map iterator.
   */
  typedef std::map<std::string, Value*>::iterator iterator;

  /**
   * Constant parameter map iterator.
   */
  typedef std::map<std::string, Value*>::const_iterator const_iterator;

  /**
   * Iterator pointing to the beginning of the set of parameters.
   */
  iterator begin();

  /**
   * Iterator pointing to the beginning of the set of parameters.
   */
  const_iterator begin() const;

  /**
   * Iterator pointing to the end of the set of parameters
   */
  iterator end();

  /**
   * Iterator pointing to the end of the set of parameters
   */
  const_iterator end() const;

private:

  /**
   * Data structure to map names with values.
   */
  std::map<std::string, Value*> _values;

};



// ------------------------------------------------------------
// Parameters::Parameter<> class inline methods

// This only works with Run-Time Type Information, even though
// typeid(T) *should* be determinable at compile time regardless...
#ifdef LIBMESH_HAVE_RTTI
template <typename T>
inline
std::string Parameters::Parameter<T>::type () const
{
  return typeid(T).name();
}
#endif



template <typename T>
inline
void Parameters::Parameter<T>::print (std::ostream& os) const
{
  os << _value;
}



template <typename T>
inline
Parameters::Value* Parameters::Parameter<T>::clone () const
{
  // No good for Solaris C++! - BSK
//  Parameters::Parameter<T>
//    *copy = new Parameters::Parameter<T>;
  Parameter<T>
    *copy = new Parameter<T>;

  libmesh_assert (copy != NULL);
  
  copy->_value = _value;

  return copy;
}


// ------------------------------------------------------------
// Parameters class inline methods
inline
void Parameters::clear () // since this is inline we must define it
{                         // before its first use (for some compilers)
  while (!_values.empty())
    {
      Parameters::iterator it = _values.begin();
      
      delete it->second;      
      it->second = NULL;
      
      _values.erase(it);
    }
}



inline
Parameters& Parameters::operator= (const Parameters& source)
{
  this->clear();

  return (*this += source);
}

inline
Parameters& Parameters::operator+= (const Parameters& source)
{
  for (Parameters::const_iterator it = source._values.begin();
       it != source._values.end(); ++it)
    _values[it->first] = it->second->clone();
  
  return *this;
}

inline
Parameters::Parameters (const Parameters& p)
{
  *this = p;
}



inline
Parameters::~Parameters ()
{
  this->clear ();
}



inline
void Parameters::print (std::ostream& os) const
{
  Parameters::const_iterator it = _values.begin();

  os << "Name\t Type\t Value\n"
     << "---------------------\n";
  while (it != _values.end())
    {
      os << " "   << it->first
#ifdef LIBMESH_HAVE_RTTI
	 << "\t " << it->second->type()
#endif // LIBMESH_HAVE_RTTI
	 << "\t ";   it->second->print(os);      
      os << '\n';

      ++it;
    }
}



// Declare this now that Paramers::print() is defined.
// By declaring this early we can use it in subsequent
// methods.  Required for gcc-4.0.2 -- 11/30/2005, BSK
inline
std::ostream& operator << (std::ostream& os, const Parameters& p)
{
  p.print(os);
  return os;
}



template <typename T>
inline
bool Parameters::have_parameter (const std::string& name) const
{
  Parameters::const_iterator it = _values.find(name);

  if (it != _values.end())
#ifdef LIBMESH_HAVE_RTTI
    if (dynamic_cast<const Parameter<T>*>(it->second) != NULL)
#else // LIBMESH_HAVE_RTTI
    if (libmesh_cast_ptr<const Parameter<T>*>(it->second) != NULL)
#endif // LIBMESH_HAVE_RTTI
      return true;

  return false;
}



template <typename T>
inline
const T& Parameters::get (const std::string& name) const
{
  if (!this->have_parameter<T>(name))
    {
      libMesh::err << "ERROR: no"
#ifdef LIBMESH_HAVE_RTTI
		    << ' ' << typeid(T).name()
#endif // LIBMESH_HAVE_RTTI
		    << " parameter named \""
		    << name << "\":" << std::endl
		    << *this;
      
      libmesh_error();
    }

  Parameters::const_iterator it = _values.find(name);

  libmesh_assert (it != _values.end());
  libmesh_assert (it->second != NULL);
  
  return libmesh_cast_ptr<Parameter<T>*>(it->second)->get();
}



template <typename T>
inline
T& Parameters::set (const std::string& name)
{
  if (!this->have_parameter<T>(name))
    _values[name] = new Parameter<T>;

  return libmesh_cast_ptr<Parameter<T>*>(_values[name])->set();
}



inline
void Parameters::remove (const std::string& name)
{
  Parameters::iterator it = _values.find(name);

  if (it != _values.end())
    {
      delete it->second;
      it->second = NULL;

      _values.erase(it);
    }
}



#ifdef LIBMESH_HAVE_RTTI
template <typename T>
inline
unsigned int Parameters::n_parameters () const
{
  unsigned int cnt = 0;  
  
  Parameters::const_iterator       it  = _values.begin();
  const Parameters::const_iterator end = _values.end();
  
  for (; it != end; ++it)
    if (dynamic_cast<Parameter<T>*>(it->second) != NULL)
      cnt++;

  return cnt;	 
}
#endif

inline
Parameters::iterator Parameters::begin()
{
  return _values.begin();
}

inline
Parameters::const_iterator Parameters::begin() const
{
  return _values.begin();
}

inline
Parameters::iterator Parameters::end()
{
  return _values.end();
}

inline
Parameters::const_iterator Parameters::end() const
{
  return _values.end();
}

} // namespace libMesh

#endif // #define __parameters_h__