cppType.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Filename: cppType.h
  2. // Created by: drose (19Oct99)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef CPPTYPE_H
  19. #define CPPTYPE_H
  20. #include <dtoolbase.h>
  21. #include "cppDeclaration.h"
  22. #include <set>
  23. class CPPType;
  24. class CPPTypedef;
  25. class CPPTypeDeclaration;
  26. // This is an STL function object used to uniquely order CPPType
  27. // pointers.
  28. class CPPTypeCompare {
  29. public:
  30. bool operator () (CPPType *a, CPPType *b) const;
  31. };
  32. ///////////////////////////////////////////////////////////////////
  33. // Class : CPPType
  34. // Description :
  35. ////////////////////////////////////////////////////////////////////
  36. class CPPType : public CPPDeclaration {
  37. public:
  38. typedef vector<CPPTypedef *> Typedefs;
  39. Typedefs _typedefs;
  40. CPPType(const CPPFile &file);
  41. virtual CPPType *resolve_type(CPPScope *current_scope,
  42. CPPScope *global_scope);
  43. virtual bool is_tbd() const;
  44. bool has_typedef_name() const;
  45. string get_typedef_name(CPPScope *scope = NULL) const;
  46. virtual string get_simple_name() const;
  47. virtual string get_local_name(CPPScope *scope = NULL) const;
  48. virtual string get_fully_scoped_name() const;
  49. virtual string get_preferred_name() const;
  50. virtual bool is_incomplete() const;
  51. virtual bool is_equivalent(const CPPType &other) const;
  52. void output_instance(ostream &out, const string &name,
  53. CPPScope *scope) const;
  54. virtual void output_instance(ostream &out, int indent_level,
  55. CPPScope *scope,
  56. bool complete, const string &prename,
  57. const string &name) const;
  58. virtual CPPType *as_type();
  59. static CPPType *new_type(CPPType *type);
  60. static void record_preferred_name_for(const CPPType *type, const string &name);
  61. static string get_preferred_name_for(const CPPType *type);
  62. CPPTypeDeclaration *_declaration;
  63. protected:
  64. typedef set<CPPType *, CPPTypeCompare> Types;
  65. static Types _types;
  66. typedef map<string, string> PreferredNames;
  67. static PreferredNames _preferred_names;
  68. };
  69. #endif