1 /*
2  * Copyright (C) 2008-2013 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2009 David Robillard <d@drobilla.net>
4  * Copyright (C) 2010-2013 Sakari Bergen <sakari.bergen@beatwaves.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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;
get_folder()67 	std::string get_folder () const { return folder; }
68 
get_time_format()69 	TimeFormat get_time_format () const { return time_format; }
get_date_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 
get_label()74 	std::string get_label () const { return label; }
get_revision()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);
set_revision(uint32_t value)82 	void set_revision (uint32_t value) { revision = value; }
set_channel(uint32_t value)83 	void set_channel (uint32_t value) { channel = value; }
84 	bool set_folder (std::string path);
85 
set_timespan(ExportTimespanPtr ts)86 	void set_timespan (ExportTimespanPtr ts) { timespan = ts; }
set_channel_config(ExportChannelConfigPtr cc)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 use_session_snapshot_name;
94 	bool include_revision;
95 	bool include_channel_config;
96 	bool include_format_name;
97 	bool include_channel;
98 	bool include_timespan;
99 	bool include_time;
100 	bool include_date;
101 
102   private:
103 
104 	Session & session;
105 
106 	std::string   label;
107 	uint32_t  revision;
108 	uint32_t  channel;
109 
110 	std::string   folder;
111 
112 	DateFormat date_format;
113 	TimeFormat time_format;
114 
115 	std::string get_formatted_time (std::string const & format) const;
116 	struct tm time_struct;
117 
118 	ExportTimespanPtr timespan;
119 	ExportChannelConfigPtr channel_config;
120 
121 	/* Serialization helpers */
122 
123 	typedef std::pair<bool, std::string> FieldPair;
124 
125 	void add_field (XMLNode * node, std::string const & name, bool enabled, std::string const & value = "");
126 	FieldPair get_field (XMLNode const & node, std::string const & name);
127 	FieldPair analyse_folder ();
128 };
129 
130 
131 } // namespace ARDOUR
132 
133 #endif /* __ardour_export_filename_h__ */
134