Fix sketchy casts.
[ardour.git] / libs / ardour / ardour / export_filename.h
1 /*
2     Copyright (C) 2008 Paul Davis
3     Author: Sakari Bergen
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #ifndef __ardour_export_filename_h__
22 #define __ardour_export_filename_h__
23
24 #include <boost/shared_ptr.hpp>
25 #include <glibmm/ustring.h>
26 #include "pbd/statefuldestructible.h"
27
28 namespace ARDOUR
29 {
30
31 class Session;
32 class ExportTimespan;
33 class ExportChannelConfiguration;
34 class ExportFormatSpecification;
35
36 class ExportFilename {
37   private:
38
39         typedef boost::shared_ptr<ExportTimespan> TimespanPtr;
40         typedef boost::shared_ptr<ExportChannelConfiguration> ChannelConfigPtr;
41         typedef boost::shared_ptr<ExportFormatSpecification const> FormatPtr;
42
43   public:
44
45         enum DateFormat {
46                 D_None,
47                 D_ISO,       // ISO 8601 full date
48                 D_ISOShortY, // Like ISO 8601, but short year representation
49                 D_BE,        // big endian (no deliminator)
50                 D_BEShortY   // big endian short year representation
51         };
52
53         enum TimeFormat {
54                 T_None,
55                 T_NoDelim,
56                 T_Delim
57         };
58
59   private:
60         friend class ExportElementFactory;
61         ExportFilename (Session & session);
62
63   public:
64         /* Serialization */
65
66         XMLNode & get_state ();
67         int set_state (const XMLNode &);
68
69         /* data access */
70
71         Glib::ustring get_path (FormatPtr format) const;
72         Glib::ustring get_folder () const { return folder; }
73
74         TimeFormat get_time_format () const { return time_format; }
75         DateFormat get_date_format () const { return date_format; }
76         Glib::ustring get_time_format_str (TimeFormat format) const;
77         Glib::ustring get_date_format_str (DateFormat format) const;
78
79         Glib::ustring get_label () const { return label; }
80         uint32_t get_revision () const { return revision; }
81
82         /* data modification */
83
84         void set_time_format (TimeFormat format);
85         void set_date_format (DateFormat format);
86         void set_label (Glib::ustring value);
87         void set_revision (uint32_t value) { revision = value; }
88         void set_channel (uint32_t value) { channel = value; }
89         bool set_folder (Glib::ustring path);
90
91         void set_timespan (TimespanPtr ts) { timespan = ts; }
92         void set_channel_config (ChannelConfigPtr cc) { channel_config = cc; }
93
94         /* public members */
95
96         bool include_label;
97         bool include_session;
98         bool include_revision;
99         bool include_channel_config;
100         bool include_channel;
101         bool include_timespan;
102         bool include_time;
103         bool include_date;
104
105   private:
106
107         Session & session;
108
109         Glib::ustring   label;
110         uint32_t  revision;
111         uint32_t  channel;
112
113         Glib::ustring   folder;
114
115         DateFormat date_format;
116         TimeFormat time_format;
117
118         Glib::ustring get_formatted_time (Glib::ustring const & format) const;
119         struct tm * time_struct; // Due to static allocation no destructor or copy-ctor is needed because of this
120
121         TimespanPtr timespan;
122         ChannelConfigPtr channel_config;
123
124         /* Serialization helpers */
125
126         typedef std::pair<bool, Glib::ustring> FieldPair;
127
128         void add_field (XMLNode * node, Glib::ustring const & name, bool enabled, Glib::ustring const & value = "");
129         FieldPair get_field (XMLNode const & node, Glib::ustring const & name);
130         FieldPair analyse_folder ();
131 };
132
133
134 } // namespace ARDOUR
135
136 #endif /* __ardour_export_filename_h__ */