Panda3D
softFilename.h
1 // Filename: softFilename.h
2 // Created by: drose (10Nov00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef SOFTFILENAME_H
16 #define SOFTFILENAME_H
17 
18 #include "pandatoolbase.h"
19 
20 ////////////////////////////////////////////////////////////////////
21 // Class : SoftFilename
22 // Description : This encapsulates a SoftImage versioned filename, of
23 // the form base.v-v.ext: it consists of a directory
24 // name, a base, a major and minor version number, and
25 // an optional extension.
26 //
27 // It also keeps track of whether the named file has
28 // been added to CVS, and how many scene files it is
29 // referenced by,
30 ////////////////////////////////////////////////////////////////////
31 class SoftFilename {
32 public:
33  SoftFilename(const string &dirname, const string &filename);
34  SoftFilename(const SoftFilename &copy);
35  void operator = (const SoftFilename &copy);
36 
37  const string &get_dirname() const;
38  const string &get_filename() const;
39  bool has_version() const;
40 
41  string get_1_0_filename() const;
42 
43  const string &get_base() const;
44  int get_major() const;
45  int get_minor() const;
46  const string &get_extension() const;
47  string get_non_extension() const;
48 
49  bool is_1_0() const;
50  void make_1_0();
51 
52  bool is_same_file(const SoftFilename &other) const;
53  bool operator < (const SoftFilename &other) const;
54 
55  void set_in_cvs(bool in_cvs);
56  bool get_in_cvs() const;
57 
58  void set_wants_cvs(bool wants_cvs);
59  bool get_wants_cvs() const;
60 
61  void increment_use_count();
62  int get_use_count() const;
63 
64 private:
65  string _dirname;
66  string _filename;
67  bool _has_version;
68  string _base;
69  int _major;
70  int _minor;
71  string _ext;
72  bool _in_cvs;
73  bool _wants_cvs;
74  int _use_count;
75 };
76 
77 #endif
string get_1_0_filename() const
Returns what the filename would be if it were version 1-0.
const string & get_dirname() const
Returns the name of the directory this file was found in.
int get_minor() const
Returns the minor version number.
bool is_1_0() const
Returns true if this is a version 1_0 filename, false otherwise.
const string & get_base() const
Returns the base part of the filename.
bool get_wants_cvs() const
Returns true if this file should be entered into the CVS database, false otherwise.
void increment_use_count()
Indicates that this filename is referenced by one more scene file.
bool operator<(const SoftFilename &other) const
Puts filenames in order such that the files with the same base are sorted together, ignoring extension; and within files with the same base, files are sorted in decreasing version number order so that the most recent version appears first.
int get_major() const
Returns the major version number.
int get_use_count() const
Returns the number of scene files that referenced this filename.
const string & get_extension() const
Returns the extension part of the filename.
const string & get_filename() const
Returns the actual filename as found in the directory.
This encapsulates a SoftImage versioned filename, of the form base.v-v.ext: it consists of a director...
Definition: softFilename.h:31
void set_in_cvs(bool in_cvs)
Sets the flag that indicates whether this file is known to be entered into the CVS database...
void set_wants_cvs(bool wants_cvs)
Sets the flag that indicates whether this file should be entered into the CVS database.
bool has_version() const
Returns true if the filename had a version number, false otherwise.
void make_1_0()
Makes this a 1_0 filename.
string get_non_extension() const
Returns the filename part, without the extension.
bool is_same_file(const SoftFilename &other) const
Returns true if this file has the same base and extension as the other, disregarding the version numb...
bool get_in_cvs() const
Returns true if this file is known to be entered in the CVS database, false if it is not...