Panda3D
Loading...
Searching...
No Matches
pandaSystem.h
Go to the documentation of this file.
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 pandaSystem.h
10 * @author drose
11 * @date 2005-01-26
12 */
13
14#ifndef PANDASYSTEM_H
15#define PANDASYSTEM_H
16
17#include "dtoolbase.h"
18#include "pmap.h"
19#include "pvector.h"
20
21/**
22 * This class is used as a namespace to group several global properties of
23 * Panda. Application developers can use this class to query the runtime
24 * version or capabilities of the current Panda environment.
25 */
26class EXPCL_DTOOL_DTOOLUTIL PandaSystem {
27protected:
28 PandaSystem();
29 ~PandaSystem();
30
31PUBLISHED:
32 static std::string get_version_string();
33 static std::string get_package_version_string();
34 static std::string get_package_host_url();
35 static std::string get_p3d_coreapi_version_string();
36
37 static int get_major_version();
38 static int get_minor_version();
39 static int get_sequence_version();
40 static bool is_official_version();
41
42 static int get_memory_alignment();
43
44 static std::string get_distributor();
45 static std::string get_compiler();
46 static std::string get_build_date();
47 static std::string get_git_commit();
48
49 static std::string get_platform();
50
51 MAKE_PROPERTY(version_string, get_version_string);
52 MAKE_PROPERTY(major_version, get_major_version);
53 MAKE_PROPERTY(minor_version, get_minor_version);
54 MAKE_PROPERTY(sequence_version, get_sequence_version);
55 MAKE_PROPERTY(official_version, is_official_version);
56
57 MAKE_PROPERTY(memory_alignment, get_memory_alignment);
58
59 MAKE_PROPERTY(distributor, get_distributor);
60 MAKE_PROPERTY(compiler, get_compiler);
61 MAKE_PROPERTY(build_date, get_build_date);
62 MAKE_PROPERTY(git_commit, get_git_commit);
63
64 MAKE_PROPERTY(platform, get_platform);
65
66 bool has_system(const std::string &system) const;
67 size_t get_num_systems() const;
68 std::string get_system(size_t n) const;
69 MAKE_SEQ(get_systems, get_num_systems, get_system);
70 MAKE_SEQ_PROPERTY(systems, get_num_systems, get_system);
71
72 std::string get_system_tag(const std::string &system, const std::string &tag) const;
73
74 void add_system(const std::string &system);
75 void set_system_tag(const std::string &system, const std::string &tag,
76 const std::string &value);
77
78 bool heap_trim(size_t pad);
79
80 void output(std::ostream &out) const;
81 void write(std::ostream &out) const;
82
83 static PandaSystem *get_global_ptr();
84
85private:
86 void reset_system_names();
87
88 void set_package_version_string(const std::string &package_version_string);
89 void set_package_host_url(const std::string &package_host_url);
90
91 typedef pmap<std::string, std::string> SystemTags;
92 typedef pmap<std::string, SystemTags> Systems;
93 typedef pvector<std::string> SystemNames;
94
95 Systems _systems;
96 SystemNames _system_names;
97 bool _system_names_dirty;
98
99 std::string _package_version_string;
100 std::string _package_host_url;
101
102 static PandaSystem *_global_ptr;
103
104public:
105 static TypeHandle get_class_type() {
106 return _type_handle;
107 }
108 static void init_type() {
109 register_type(_type_handle, "PandaSystem");
110 }
111
112private:
113 static TypeHandle _type_handle;
114
115 friend class ConfigPageManager;
116};
117
118inline std::ostream &operator << (std::ostream &out, const PandaSystem &ps) {
119 ps.output(out);
120 return out;
121}
122
123#endif
This class is used as a namespace to group several global properties of Panda.
Definition pandaSystem.h:26
get_num_systems
Returns the number of Panda subsystems that have registered themselves.
Definition pandaSystem.h:69
get_sequence_version
Returns the sequence version number of the current version of Panda.
Definition pandaSystem.h:54
get_build_date
Returns a string representing the date and time at which this version of Panda (or at least dtool) wa...
Definition pandaSystem.h:61
is_official_version
Returns true if current version of Panda claims to be an "official" version, that is,...
Definition pandaSystem.h:55
get_system
Returns the nth Panda subsystem that has registered itself.
Definition pandaSystem.h:69
void set_system_tag(const std::string &system, const std::string &tag, const std::string &value)
Intended for use by each subsystem to register its set of capabilities at startup.
get_major_version
Returns the major version number of the current version of Panda.
Definition pandaSystem.h:52
get_platform
Returns a string representing the runtime platform that we are currently running on.
Definition pandaSystem.h:64
get_memory_alignment
Returns the memory alignment that Panda's allocators are using.
Definition pandaSystem.h:57
get_version_string
Returns the current version of Panda, expressed as a string, e.g.
Definition pandaSystem.h:51
get_git_commit
Returns a string representing the git commit hash that this source tree is based on,...
Definition pandaSystem.h:62
static std::string get_package_host_url()
Returns the URL of the download server that provides the Panda3D distributable package currently runn...
get_minor_version
Returns the minor version number of the current version of Panda.
Definition pandaSystem.h:53
get_distributor
Returns the string defined by the distributor of this version of Panda, or "homebuilt" if this versio...
Definition pandaSystem.h:59
get_compiler
Returns a string representing the compiler that was used to generate this version of Panda,...
Definition pandaSystem.h:60
static PandaSystem * get_global_ptr()
Returns the global PandaSystem object.
static std::string get_p3d_coreapi_version_string()
Returns the current version of Panda's Core API, expressed as a string of dot-delimited integers.
void add_system(const std::string &system)
Intended for use by each subsystem to register itself at startup.
bool has_system(const std::string &system) const
Returns true if the current version of Panda claims to have the indicated subsystem installed,...
std::string get_system_tag(const std::string &system, const std::string &tag) const
Returns the value associated with the indicated tag for the given system.
static std::string get_package_version_string()
Returns the version of the Panda3D distributable package that provides this build of Panda.
bool heap_trim(size_t pad)
Attempts to release memory back to the system, if possible.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...