cppStructType.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 cppStructType.h
  10. * @author drose
  11. * @date 1999-10-19
  12. */
  13. #ifndef CPPSTRUCTTYPE_H
  14. #define CPPSTRUCTTYPE_H
  15. #include "dtoolbase.h"
  16. #include "cppIdentifier.h"
  17. #include "cppExtensionType.h"
  18. #include "cppFunctionGroup.h"
  19. #include "cppVisibility.h"
  20. #include <vector>
  21. #include <list>
  22. class CPPScope;
  23. class CPPTypeProxy;
  24. /**
  25. *
  26. */
  27. class CPPStructType : public CPPExtensionType {
  28. public:
  29. CPPStructType(Type type, CPPIdentifier *ident,
  30. CPPScope *current_scope,
  31. CPPScope *scope,
  32. const CPPFile &file);
  33. CPPStructType(const CPPStructType &copy);
  34. void operator = (const CPPStructType &copy);
  35. void append_derivation(CPPType *base, CPPVisibility vis, bool is_virtual);
  36. CPPScope *get_scope() const;
  37. bool is_abstract() const;
  38. bool is_base_of(const CPPStructType *other) const;
  39. bool is_empty() const;
  40. bool is_polymorphic() const;
  41. bool check_virtual() const;
  42. bool has_virtual_destructor() const;
  43. virtual bool is_fully_specified() const;
  44. virtual bool is_incomplete() const;
  45. virtual bool is_standard_layout() const;
  46. virtual bool is_trivial() const;
  47. virtual bool is_constructible(const CPPType *arg_type) const;
  48. virtual bool is_default_constructible() const;
  49. virtual bool is_copy_constructible() const;
  50. virtual bool is_destructible() const;
  51. bool is_default_constructible(CPPVisibility min_vis) const;
  52. bool is_copy_constructible(CPPVisibility min_vis) const;
  53. bool is_move_constructible(CPPVisibility min_vis) const;
  54. bool is_destructible(CPPVisibility min_vis) const;
  55. virtual bool is_convertible_to(const CPPType *other) const;
  56. inline bool is_final() const { return _final; }
  57. CPPFunctionGroup *get_constructor() const;
  58. CPPInstance *get_default_constructor() const;
  59. CPPInstance *get_copy_constructor() const;
  60. CPPInstance *get_move_constructor() const;
  61. CPPInstance *get_destructor() const;
  62. virtual CPPDeclaration *
  63. instantiate(const CPPTemplateParameterList *actual_params,
  64. CPPScope *current_scope, CPPScope *global_scope,
  65. CPPPreprocessor *error_sink = NULL) const;
  66. virtual CPPDeclaration *substitute_decl(SubstDecl &subst,
  67. CPPScope *current_scope,
  68. CPPScope *global_scope);
  69. virtual void output(ostream &out, int indent_level, CPPScope *scope,
  70. bool complete) const;
  71. virtual SubType get_subtype() const;
  72. virtual CPPStructType *as_struct_type();
  73. CPPScope *_scope;
  74. bool _incomplete;
  75. bool _final;
  76. class Base {
  77. public:
  78. void output(ostream &out) const;
  79. CPPType *_base;
  80. CPPVisibility _vis;
  81. bool _is_virtual;
  82. };
  83. typedef vector<Base> Derivation;
  84. Derivation _derivation;
  85. typedef list<CPPInstance *> VFunctions;
  86. void get_virtual_funcs(VFunctions &funcs) const;
  87. void get_pure_virtual_funcs(VFunctions &funcs) const;
  88. protected:
  89. virtual bool is_equal(const CPPDeclaration *other) const;
  90. virtual bool is_less(const CPPDeclaration *other) const;
  91. bool _subst_decl_recursive_protect;
  92. typedef vector<CPPTypeProxy *> Proxies;
  93. Proxies _proxies;
  94. };
  95. inline ostream &operator << (ostream &out, const CPPStructType::Base &base) {
  96. base.output(out);
  97. return out;
  98. }
  99. #endif