consistent API name for region-list
[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
26 #include <string>
27
28 #include <ardour/export_pointers.h>
29
30 #include "pbd/statefuldestructible.h"
31
32 namespace ARDOUR
33 {
34
35 class Session;
36
37 class LIBARDOUR_API ExportFilename {
38   public:
39
40         enum DateFormat {
41                 D_None,
42                 D_ISO,       // ISO 8601 full date
43                 D_ISOShortY, // Like ISO 8601, but short year representation
44                 D_BE,        // big endian (no deliminator)
45                 D_BEShortY   // big endian short year representation
46         };
47
48         enum TimeFormat {
49                 T_None,
50                 T_NoDelim,
51                 T_Delim
52         };
53
54   private:
55         friend class ExportElementFactory;
56         ExportFilename (Session & session);
57
58   public:
59         /* Serialization */
60
61         XMLNode & get_state ();
62         int set_state (const XMLNode &);
63
64         /* data access */
65
66         std::string get_path (ExportFormatSpecPtr format) const;
67         std::string get_folder () const { return folder; }
68
69         TimeFormat get_time_format () const { return time_format; }
70         DateFormat get_date_format () const { return date_format; }
71         std::string get_time_format_str (TimeFormat format) const;
72         std::string get_date_format_str (DateFormat format) const;
73
74         std::string get_label () const { return label; }
75         uint32_t get_revision () const { return revision; }
76
77         /* data modification */
78
79         void set_time_format (TimeFormat format);
80         void set_date_format (DateFormat format);
81         void set_label (std::string value);
82         void set_revision (uint32_t value) { revision = value; }
83         void set_channel (uint32_t value) { channel = value; }
84         bool set_folder (std::string path);
85
86         void set_timespan (ExportTimespanPtr ts) { timespan = ts; }
87         void set_channel_config (ExportChannelConfigPtr cc) { channel_config = cc; }
88
89         /* public members */
90
91         bool include_label;
92         bool include_session;
93         bool include_revision;
94         bool include_channel_config;
95         bool include_format_name;
96         bool include_channel;
97         bool include_timespan;
98         bool include_time;
99         bool include_date;
100
101   private:
102
103         Session & session;
104
105         std::string   label;
106         uint32_t  revision;
107         uint32_t  channel;
108
109         std::string   folder;
110
111         DateFormat date_format;
112         TimeFormat time_format;
113
114         std::string get_formatted_time (std::string const & format) const;
115         struct tm time_struct;
116
117         ExportTimespanPtr timespan;
118         ExportChannelConfigPtr channel_config;
119
120         /* Serialization helpers */
121
122         typedef std::pair<bool, std::string> FieldPair;
123
124         void add_field (XMLNode * node, std::string const & name, bool enabled, std::string const & value = "");
125         FieldPair get_field (XMLNode const & node, std::string const & name);
126         FieldPair analyse_folder ();
127 };
128
129
130 } // namespace ARDOUR
131
132 #endif /* __ardour_export_filename_h__ */