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