cppType.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file cppType.h
  10. * @author drose
  11. * @date 1999-10-19
  12. */
  13. #ifndef CPPTYPE_H
  14. #define CPPTYPE_H
  15. #include "dtoolbase.h"
  16. #include "cppDeclaration.h"
  17. #include <set>
  18. class CPPType;
  19. class CPPTypedefType;
  20. class CPPTypeDeclaration;
  21. // This is an STL function object used to uniquely order CPPType pointers.
  22. class CPPTypeCompare {
  23. public:
  24. bool operator () (CPPType *a, CPPType *b) const;
  25. };
  26. /**
  27. *
  28. */
  29. class CPPType : public CPPDeclaration {
  30. public:
  31. typedef vector<CPPTypedefType *> Typedefs;
  32. Typedefs _typedefs;
  33. CPPType(const CPPFile &file);
  34. virtual CPPType *resolve_type(CPPScope *current_scope,
  35. CPPScope *global_scope);
  36. virtual bool is_tbd() const;
  37. virtual bool is_trivial() const;
  38. virtual bool is_default_constructible() const;
  39. virtual bool is_copy_constructible() const;
  40. virtual bool is_parameter_expr() const;
  41. bool has_typedef_name() const;
  42. string get_typedef_name(CPPScope *scope = NULL) const;
  43. virtual string get_simple_name() const;
  44. virtual string get_local_name(CPPScope *scope = NULL) const;
  45. virtual string get_fully_scoped_name() const;
  46. virtual string get_preferred_name() const;
  47. int get_num_alt_names() const;
  48. string get_alt_name(int n) const;
  49. virtual bool is_incomplete() const;
  50. virtual bool is_equivalent(const CPPType &other) const;
  51. void output_instance(ostream &out, const string &name,
  52. CPPScope *scope) const;
  53. virtual void output_instance(ostream &out, int indent_level,
  54. CPPScope *scope,
  55. bool complete, const string &prename,
  56. const string &name) const;
  57. virtual CPPType *as_type();
  58. static CPPType *new_type(CPPType *type);
  59. static void record_alt_name_for(const CPPType *type, const string &name);
  60. static string get_preferred_name_for(const CPPType *type);
  61. CPPTypeDeclaration *_declaration;
  62. bool _forcetype;
  63. protected:
  64. typedef set<CPPType *, CPPTypeCompare> Types;
  65. static Types _types;
  66. typedef map<string, string> PreferredNames;
  67. static PreferredNames _preferred_names;
  68. typedef vector<string> Names;
  69. typedef map<string, Names> AltNames;
  70. static AltNames _alt_names;
  71. };
  72. #endif