This file is indexed.

/usr/include/sc/util/class/class.h is in libsc-dev 2.3.1-18build1.

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
//
// class.h
//
// Copyright (C) 1996 Limit Point Systems, Inc.
//
// Author: Curtis Janssen <cljanss@limitpt.com>
// Maintainer: LPS
//
// This file is part of the SC Toolkit.
//
// The SC Toolkit is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// The SC Toolkit 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 Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public License
// along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
//
// The U.S. Government is granted a limited license as per AL 91-7.
//

#ifdef __GNUG__
#pragma interface
#endif

#ifndef _util_class_class_h
#define _util_class_class_h

#include <map>
#include <set>
#include <string>

#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <iostream>
#include <iomanip>
#include <typeinfo>
#include <util/ref/ref.h>
#include <util/misc/exenv.h>

namespace sc {

template <class T, class C>
class DescribedMemberDatum {
  private:
    T C::*member_;
  public:
    DescribedMemberDatum(T C::*member): member_(member) {}
    //T &member(C *c) { return c->*member_; }
};

class DescribedClass;
class ClassDesc;
typedef ClassDesc* ClassDescP;
typedef const ClassDesc* CClassDescP;

class ClassDesc;

/// Gives one parent class of a class.
class ParentClass
{
  public:
    enum Access { Private, Protected, Public };
  private:
    Access _access;
    int _is_virtual;
    ClassDesc* _classdesc;
  public:
    ParentClass(ClassDesc*,Access access = Private,int is_virtual = 0);
    ParentClass(const ParentClass&);
    ~ParentClass();
    int is_virtual() const;
    Access access() const { return _access; }
    const ClassDesc* classdesc() const;
    void change_classdesc(ClassDesc*n);
};

/// Gives a list of parent classes of a class.
class ParentClasses
{
  private:
    int _n;
    ParentClass** _classes;
    void add(ParentClass*);
    // do not allow copy constructor or assignment
    ParentClasses(const ParentClasses&);
    void operator=(const ParentClasses&);
  public:
    ParentClasses();
    void init(const char*);
    ~ParentClasses();
    ParentClass& parent(int i) { return *_classes[i]; }
    const ParentClass& parent(int i) const { return *_classes[i]; }
    ParentClass& operator[](int i) { return *_classes[i]; }
    const ParentClass& operator[](int i) const { return *_classes[i]; }
    int n() const { return _n; }
    void change_parent(ClassDesc*oldcd,ClassDesc*newcd);
};
    

class KeyVal;
class StateIn;

/** This is used to pass a function that make void constructor calls to the
    ClassDesc constructor. */
template <class T>
DescribedClass* create()
{
  return new T;
}

/** This is used to pass a function that make KeyVal constructor calls to
    the ClassDesc constructor. */
template <class T>
DescribedClass* create(const Ref<KeyVal>& keyval)
{
  return new T(keyval);
}

/** This is used to pass a function that make StateIn constructor calls to
    the ClassDesc constructor. */
template <class T>
DescribedClass* create(StateIn& statein)
{
  return new T(statein);
}

class type_info_key {
  private:
    const std::type_info *ti_;
  public:
    type_info_key(): ti_(0) {}
    type_info_key(const std::type_info *ti): ti_(ti) {}
    type_info_key& operator=(const type_info_key&);
    int operator==(const type_info_key&) const;
    int operator<(const type_info_key&) const;
    int cmp(const type_info_key&) const;
};

/** This class is used to contain information about classes.
 Each DescribedClass type has a static ClassDesc
 member.  This member has lists of the parents, children
 and virtual parents for each class.  The
 ClassDesc class also has a static member that is
 a list of all described classes in the system.  These
 lists are constructed as the constructors for the static
 ClassDesc members for each class are called and
 are completed before main is entered.  See \ref class for
 more information.
*/
class ClassDesc: public Identity {
    friend class ParentClasses;
  private:
    static std::map<std::string,ClassDescP> *all_;
    static std::map<type_info_key,ClassDescP> *type_info_all_;
    static char * classlib_search_path_;
    static std::set<std::string> *unresolved_parents_;

    char* classname_;
    int version_;
    ParentClasses parents_;
    std::set<std::string> *children_;
    DescribedClass* (*ctor_)();
    DescribedClass* (*keyvalctor_)(const Ref<KeyVal>&);
    DescribedClass* (*stateinctor_)(StateIn&);
    const std::type_info *ti_;

    void change_parent(ClassDesc*oldcd,ClassDesc*newcd);

    // do not allow copy constructor or assignment
    ClassDesc(const ClassDesc&);
    void operator=(const ClassDesc&);

    // this is used for temporary parent class descriptors
    ClassDesc(const char*);
    void init(const char*,int=1,const char* p=0,
              const std::type_info *ti=0,
              DescribedClass* (*ctor)()=0,
              DescribedClass* (*keyvalctor)(const Ref<KeyVal>&)=0,
              DescribedClass* (*stateinctor)(StateIn&)=0);
  public:
    ClassDesc(const std::type_info&, const char*,int=1,const char* p=0,
              DescribedClass* (*ctor)()=0,
              DescribedClass* (*keyvalctor)(const Ref<KeyVal>&)=0,
              DescribedClass* (*stateinctor)(StateIn&)=0);
    ~ClassDesc();

    static std::map<std::string,ClassDescP>& all();
    const ParentClasses& parents() const { return parents_; }

    /// Writes a list of all of the classes to ExEnv::out0().
    static void list_all_classes();
    /** Given the name of the class, return a pointer to the
        class descriptor. */
    static ClassDesc* name_to_class_desc(const char*);
    /** Given a type_info object return a pointer to the ClassDesc. */
    static ClassDesc *class_desc(const std::type_info &);
    /// Returns the name of the class.
    const char* name() const { return classname_; }
    /// Returns the version number of the class.
    int version() const { return version_; }
    /// This member has been replaced by create().
    DescribedClass* create_described_class() const;
    /** Create an instance of DescribedClass with
        exact type equal to the class to which this class
        descriptor belongs.  The constructor which takes no
        arguments is used.  If this constructor doesn't exist or
        a static function that calls it with new wasn't
        given to this ClassDesc when it was created, then
        0 will be returned. */
    virtual DescribedClass* create() const;
    /** Create an instance of DescribedClass with exact type equal to the
        class to which this class descriptor belongs.  The KeyVal&
        constructor is used.  If this constructor doesn't exist or a static
        function that calls it with new wasn't passed to this ClassDesc,
        then 0 will be returned. */
    virtual DescribedClass* create(const Ref<KeyVal>&) const;
    /** Create an instance of DescribedClass with exact type equal to the
        class to which this class descriptor belongs.  The StateIn&
        constructor is used.  If this constructor doesn't exist or a static
        function that calls it with new wasn't passed to this ClassDesc,
        then 0 will be returned. */
    virtual DescribedClass* create(StateIn&) const;

    /** Attempt to dynamically load the shared object file for
        classname. */
    static int load_class(const char* classname);
};

/** Classes which need runtime information about themselves and their
    relationship to other classes can virtually inherit from
    DescribedClass.  This will provide the class with the ability to query
    its name and its version.
    Furthermore, the class's static ClassDesc can be obtained
    which permits several other operations.  See \ref class for
    more information. */
class DescribedClass : public RefCount {
  public:
    DescribedClass();
    DescribedClass(const DescribedClass&);
    DescribedClass& operator=(const DescribedClass&);
    virtual ~DescribedClass();
    /** This returns the unique pointer to the ClassDesc corresponding
        to the given type_info object.  Null is returned if it fails. */
    ClassDesc* class_desc() const throw();
    /// Return the name of the object's exact type.
    const char* class_name() const;
    /// Return the version of the class.
    int class_version() const;
    /// Print the object.
    virtual void print(std::ostream& = ExEnv::out0()) const;
  };

/** Return the ClassDesc corresponding to template argument. */
template <class T>
inline ClassDesc *
class_desc()
{
  return ClassDesc::class_desc(typeid(T));
}

/** Return the ClassDesc corresponding to the exact type for the
    argument. */
inline ClassDesc *
class_desc(DescribedClass *d)
{
  return ClassDesc::class_desc(typeid(*d));
}

/** Attempt to cast a DescribedClass pointer to a DescribedClass
    descendent.  It is an error for the result to be a null pointer. */
template<class T>
inline T
require_dynamic_cast(DescribedClass*p,const char * errmsg,...)
{
  T t = dynamic_cast<T>(p);
  if (p && !t) {
      va_list args;
      va_start(args,errmsg);
      fprintf(stderr,"A required dynamic_cast failed in: ");
      vfprintf(stderr,errmsg,args);
      fprintf(stderr,"\nwanted type \"%s\" but got \"%s\"\n",
              typeid(T).name(),p->class_desc()->name());
      fflush(stderr);
      va_end(args);
      abort();
  }
  return t;
}

/** Attempt to cast a const DescribedClass pointer to a DescribedClass
    descendent.  It is an error for the result to be a null pointer. */
template<class T>
inline T
require_dynamic_cast(const DescribedClass*p,const char * errmsg,...)
{
  T t = dynamic_cast<T>(p);
  if (p && !t) {
      va_list args;
      va_start(args,errmsg);
      fprintf(stderr,"A required dynamic_cast failed in: ");
      vfprintf(stderr,errmsg,args);
      fprintf(stderr,"\nwanted type \"%s\" but got \"%s\"\n",
              typeid(T).name(),p->class_desc()->name());
      fflush(stderr);
      va_end(args);
      abort();
  }
  return t;
}

/** This, together with ForceLink, is used to force code for particular
    classes to be linked into executables. */
template <class A>
class ForceLinkBase {
  public:
    ForceLinkBase() {};
    virtual ~ForceLinkBase() {};
    virtual DescribedClass *create(A) = 0;
};

/** This, together with ForceLinkBase, is used to force code for particular
classes to be linked into executables.  Objects are created from input and
checkpoint files by using class name lookup to find that class's ClassDesc
object.  The ClassDesc object has members that can create the class.
Unfortunately, linking in a library doesn't cause code for the the
ClassDesc, and thus the class itself, to be linked.  ForceLink objects are
created in linkage.h files for each library.  The code containing the main
routine for an executable can include these linkage files to force code for
that library's classes to be linked. */
template <class T, class A = const Ref<KeyVal> &>
class ForceLink: public ForceLinkBase<A> {
  public:
    ForceLink() {};
    virtual ~ForceLink() {};
    DescribedClass *create(A a) { return new T(a); }
};

}

#endif

// Local Variables:
// mode: c++
// c-file-style: "CLJ"
// End: