30 "dcparse [options] [file1 file2 ...]\n"
38 "This program reads one or more DC files, which are used to describe the\n"
39 "communication channels in the distributed class system. By default,\n"
40 "the file(s) are read and concatenated, and a single hash code is printed\n"
41 "corresponding to the file's contents.\n\n"
45 " -v Writes a complete parseable version of the file to standard\n"
46 " output instead of printing a hash code.\n\n"
48 " -b Writes a brief parseable version of the file instead of a full\n"
49 " version. This is semantically the same as the output produced\n"
50 " the above -v option--reading it would produce exactly the same\n"
51 " results--but it is designed to be slightly obfuscated. The\n"
52 " comments and parameter names are not included.\n\n"
54 " -c Write a list of class names, showing the inheritance hierarchy.\n"
55 " Some class names will be listed twice in the presence of multiple\n"
58 " -f Write a complete list of field names available for each class,\n"
59 " including all inherited fields.\n\n";
63 write_class_hierarchy(
int indent_level,
const DCFile &file,
69 for (
int i = 0; i < num_classes; ++i) {
71 bool is_my_child =
false;
73 for (
int j = 0; j < num_parents && !is_my_child; ++j) {
74 is_my_child = (dclass->
get_parent(j) == this_dclass);
78 write_class_hierarchy(indent_level + 2, file, dclass);
84 write_class_hierarchy(
const DCFile &file) {
86 for (
int i = 0; i < num_classes; ++i) {
89 write_class_hierarchy(0, file, dclass);
96 write_complete_field_list(
const DCFile &file) {
98 for (
int i = 0; i < num_classes; ++i) {
100 cout <<
"\n" << dclass->
get_name() <<
"\n";
102 for (
int j = 0; j < num_inherited_fields; ++j) {
114 field->output_keywords(cout);
121 main(
int argc,
char *argv[]) {
124 const char *optstr =
"bvcfh";
126 bool dump_verbose =
false;
127 bool dump_brief =
false;
128 bool dump_classes =
false;
129 bool dump_fields =
false;
131 int flag = getopt(argc, argv, optstr);
133 while (flag != EOF) {
158 flag = getopt(argc, argv, optstr);
170 for (
int i = 1; i < argc; i++) {
171 if (!file.
read(argv[i])) {
177 cerr <<
"File is incomplete. The following objects are undefined:\n";
181 for (i = 0; i < num_typedefs; i++) {
184 cerr <<
" " << dtypedef->
get_name() <<
"\n";
189 for (i = 0; i < num_classes; i++) {
192 cerr <<
" " << dclass->
get_name() <<
"\n";
199 if (dump_verbose || dump_brief) {
200 if (!file.
write(cout, dump_brief)) {
204 }
else if (dump_classes) {
205 write_class_hierarchy(file);
207 }
else if (dump_fields) {
208 write_complete_field_list(file);
211 unsigned long hash = file.
get_hash();
212 cerr <<
"File hash is " << hash <<
" (signed " << (long)hash <<
")\n";
215 #ifdef DO_MEMORY_USAGE
219 for (
int i = 1; i < argc; i++) {
Defines a particular DistributedClass as read from an input .dc file.
DCField * get_inherited_field(int n) const
Returns the nth field field in the class and all of its ancestors.
DCClass * get_parent(int n) const
Returns the nth parent class this class inherits from.
bool is_bogus_class() const
Returns true if the class has been flagged as a bogus class.
int get_num_inherited_fields() const
Returns the total number of field fields defined in this class and all ancestor classes.
const std::string & get_name() const
Returns the name of this class.
int get_num_parents() const
Returns the number of base classes this class inherits from.
A single field of a Distributed Class, either atomic or molecular.
DCClass * get_class() const
Returns the DCClass pointer for the class that contains this field.
virtual DCAtomicField * as_atomic_field()
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic fie...
virtual DCMolecularField * as_molecular_field()
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular...
Represents the complete list of Distributed Class descriptions as read from a .dc file.
unsigned long get_hash() const
Returns a 32-bit hash index associated with this file.
bool all_objects_valid() const
Returns true if all of the classes read from the DC file were defined and valid, or false if any of t...
int get_num_typedefs() const
Returns the number of typedefs read from the .dc file(s).
DCTypedef * get_typedef(int n) const
Returns the nth typedef read from the .dc file(s).
int get_num_classes() const
Returns the number of classes read from the .dc file(s).
bool write(Filename filename, bool brief) const
Opens the indicated filename for output and writes a parseable description of all the known distribut...
bool read(Filename filename)
Opens and reads the indicated .dc file by name.
DCClass * get_class(int n) const
Returns the nth class read from the .dc file(s).
void clear()
Removes all of the classes defined within the DCFile and prepares it for reading a new file.
const std::string & get_name() const
Returns the name of this field, or empty string if the field is unnamed.
This represents a single typedef declaration in the dc file.
const std::string & get_name() const
Returns the name of this typedef.
bool is_bogus_typedef() const
Returns true if the typedef has been flagged as a bogus typedef.
static void show_current_types()
Shows the breakdown of types of all of the active pointers.
is_tracking
Returns true if the MemoryUsage object is currently tracking memory (e.g.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.