HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fileFormat.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_USD_SDF_FILE_FORMAT_H
25 #define PXR_USD_SDF_FILE_FORMAT_H
26 
27 /// \file sdf/fileFormat.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/ar/ar.h"
31 #include "pxr/usd/sdf/api.h"
34 #include "pxr/base/tf/refBase.h"
36 #include "pxr/base/tf/token.h"
37 #include "pxr/base/tf/type.h"
38 #include "pxr/base/tf/weakBase.h"
39 
40 #include <map>
41 #include <string>
42 #include <vector>
43 
45 
46 class ArAssetInfo;
47 class SdfSchemaBase;
48 class SdfLayerHints;
49 
54 
55 #define SDF_FILE_FORMAT_TOKENS \
56  ((TargetArg, "target"))
57 
59 
60 /// \class SdfFileFormat
61 ///
62 /// Base class for file format implementations.
63 ///
65  : public TfRefBase
66  , public TfWeakBase
67 {
68 public:
69  SdfFileFormat(const SdfFileFormat&) = delete;
70  SdfFileFormat& operator=(const SdfFileFormat&) = delete;
71 
72  /// Returns the schema for this format.
73  SDF_API const SdfSchemaBase& GetSchema() const;
74 
75  /// Returns the format identifier.
76  SDF_API const TfToken& GetFormatId() const;
77 
78  /// Returns the target for this file format.
79  SDF_API const TfToken& GetTarget() const;
80 
81  /// Returns the cookie to be used when writing files with this format.
82  SDF_API const std::string& GetFileCookie() const;
83 
84  /// Returns the current version of this file format.
85  SDF_API const TfToken& GetVersionString() const;
86 
87  /// Returns true if this file format is the primary format for the
88  /// extensions it handles.
90 
91  /// Returns a list of extensions that this format supports.
92  SDF_API const std::vector<std::string>& GetFileExtensions() const;
93 
94  /// Returns the primary file extension for this format. This is the
95  /// extension that is reported for layers using this file format.
97 
98  /// Returns true if \p extension matches one of the extensions returned by
99  /// GetFileExtensions.
101 
102  /// Returns true if this file format is a package containing other
103  /// assets.
104  SDF_API
105  virtual bool IsPackage() const;
106 
107  /// Returns the path of the "root" layer contained in the package
108  /// layer at \p resolvedPath produced by this file format. If this
109  /// file format is not a package, returns the empty string.
110  ///
111  /// The package root layer is the layer in the package layer that
112  /// is used when that package is opened via SdfLayer.
113  SDF_API
115  const std::string& resolvedPath) const;
116 
117  /// Type for specifying additional file format-specific arguments
118  /// to the various API below.
119  typedef std::map<std::string, std::string> FileFormatArguments;
120 
121  /// Returns the FileFormatArguments that correspond to the default behavior
122  /// of this file format when no FileFormatArguments are passed to NewLayer
123  /// or InitData.
124  SDF_API
126 
127  /// This method allows the file format to bind to whatever data container is
128  /// appropriate.
129  ///
130  /// Returns a shared pointer to an SdfAbstractData implementation.
131  SDF_API
132  virtual SdfAbstractDataRefPtr
133  InitData(const FileFormatArguments& args) const;
134 
135  /// Returns a new SdfAbstractData providing access to the layer's data.
136  /// This data object is detached from any underlying storage.
137  SDF_API
138  SdfAbstractDataRefPtr InitDetachedData(
139  const FileFormatArguments& args) const;
140 
141  /// Instantiate a layer.
142  SDF_API
143  SdfLayerRefPtr NewLayer(const SdfFileFormatConstPtr &fileFormat,
144  const std::string &identifier,
145  const std::string &realPath,
146  const ArAssetInfo& assetInfo,
147  const FileFormatArguments &args) const;
148 
149  /// Return true if this file format prefers to skip reloading anonymous
150  /// layers.
151  SDF_API bool ShouldSkipAnonymousReload() const;
152 
153  /// Returns true if anonymous layer identifiers should be passed to Read
154  /// when a layer is opened or reloaded.
155  ///
156  /// Anonymous layers will not have an asset backing and thus for most
157  /// file formats there is nothing that can be read for an anonymous layer.
158  /// However, there are file formats that use Read to generate dynamic layer
159  /// content without reading any data from the resolved asset associated with
160  /// the layer's identifier.
161  ///
162  /// For these types of file formats it is useful to be able to open
163  /// anonymous layers and allow Read to populate them to avoid requiring a
164  /// placeholder asset to exist just so Read can populate the layer.
165  SDF_API bool ShouldReadAnonymousLayers() const;
166 
167  /// Returns true if \p file can be read by this format.
168  SDF_API
169  virtual bool CanRead(
170  const std::string& file) const = 0;
171 
172  /// Reads scene description from the asset specified by \p resolvedPath
173  /// into the layer \p layer.
174  ///
175  /// \p metadataOnly is a flag that asks for only the layer metadata
176  /// to be read in, which can be much faster if that is all that is
177  /// required. Note that this is just a hint: some FileFormat readers
178  /// may disregard this flag and still fully populate the layer contents.
179  ///
180  /// Returns true if the asset is successfully read into \p layer,
181  /// false otherwise.
182  SDF_API
183  virtual bool Read(
184  SdfLayer* layer,
185  const std::string& resolvedPath,
186  bool metadataOnly) const = 0;
187 
188  /// Reads scene description from the asset specified by \p resolvedPath
189  /// into the detached layer \p layer. After reading is completed,
190  /// \p layer must be detached from any underlying storage.
191  ///
192  /// \p metadataOnly is a flag that asks for only the layer metadata
193  /// to be read in, which can be much faster if that is all that is
194  /// required. Note that this is just a hint: some FileFormat readers
195  /// may disregard this flag and still fully populate the layer contents.
196  ///
197  /// Returns true if the asset is successfully read into \p layer,
198  /// false if the the asset could not be read or if the resulting
199  /// layer is not detached.
200  SDF_API
201  bool ReadDetached(
202  SdfLayer* layer,
203  const std::string& resolvedPath,
204  bool metadataOnly) const;
205 
206  /// Writes the content in \p layer into the file at \p filePath. If the
207  /// content is successfully written, this method returns true. Otherwise,
208  /// false is returned and errors are posted. The default implementation
209  /// returns false.
210  SDF_API
211  virtual bool WriteToFile(
212  const SdfLayer& layer,
213  const std::string& filePath,
214  const std::string& comment = std::string(),
215  const FileFormatArguments& args = FileFormatArguments()) const;
216 
217  /// Reads data in the string \p str into the layer \p layer. If
218  /// the file is successfully read, this method returns true. Otherwise,
219  /// false is returned and errors are posted.
220  SDF_API
221  virtual bool ReadFromString(
222  SdfLayer* layer,
223  const std::string& str) const;
224 
225  /// Write the provided \p spec to \p out indented \p indent levels.
226  SDF_API
227  virtual bool WriteToStream(
228  const SdfSpecHandle &spec,
229  std::ostream& out,
230  size_t indent) const;
231 
232  /// Writes the content in \p layer to the string \p str. This function
233  /// should write a textual representation of \p layer to the stream
234  /// that can be read back in via ReadFromString.
235  SDF_API
236  virtual bool WriteToString(
237  const SdfLayer& layer,
238  std::string* str,
239  const std::string& comment = std::string()) const;
240 
241  /// Returns the set of resolved paths to external asset file dependencies
242  /// for the given \p layer. These are additional dependencies, specific to
243  /// the file format, that are needed when generating the layer's contents
244  /// and would not otherwise be discoverable through composition dependencies
245  /// (i.e. sublayers, references, and payloads).
246  ///
247  /// The default implementation returns an empty set. Derived file formats
248  /// that depend on external assets to read and generate layer content
249  /// should implement this function to return the external asset paths.
250  ///
251  /// \sa SdfLayer::GetExternalAssetDependencies
252  /// \sa SdfLayer::Reload
253  SDF_API
254  virtual std::set<std::string> GetExternalAssetDependencies(
255  const SdfLayer& layer) const;
256 
257 
258  /// Returns true if this file format supports reading.
259  /// This is a convenience method for invoking \ref FormatSupportsReading
260  /// with this format's extension and target
261  SDF_API bool SupportsReading() const;
262 
263  // Returns true if this file format supports writing.
264  /// This is a convenience method for invoking \ref FormatSupportsWriting
265  /// with this format's extension and target
266  SDF_API bool SupportsWriting() const;
267 
268  // Returns true if this file format supports editing.
269  /// This is a convenience method for invoking \ref FormatSupportsEditing
270  /// with this format's extension and target
271  SDF_API bool SupportsEditing() const;
272 
273  /// Returns the file extension for path or file name \p s, without the
274  /// leading dot character.
276 
277  /// Returns a set containing the extension(s) corresponding to
278  /// all registered file formats.
279  SDF_API static std::set<std::string> FindAllFileFormatExtensions();
280 
281  /// Returns a set containing the extension(s) corresponding to
282  /// all registered file formats that derive from \p baseType.
283  ///
284  /// \p baseType must derive from SdfFileFormat.
285  SDF_API static std::set<std::string> FindAllDerivedFileFormatExtensions(
286  const TfType& baseType);
287 
288  /// Returns true if the file format for the supplied \p extension and
289  /// \p target pair supports reading.
290  /// This method will not load the plugin that provides the specified
291  /// file format.
292  /// If the extension and target pair is invalid, this method will
293  /// return false.
294  /// \sa FormatSupportsWriting \sa FormatSupportsEditing
295  SDF_API
296  static bool FormatSupportsReading(
297  const std::string& extension,
298  const std::string& target = std::string());
299 
300  /// Returns true if the file format for the supplied \p extension and
301  /// \p target pair supports writing.
302  /// This method will not load the plugin that provides the specified
303  /// file format.
304  /// If the extension and target pair is invalid, this method will return
305  /// false.
306  /// \sa FormatSupportsReading \sa FormatSupportsEditing
307  SDF_API
308  static bool FormatSupportsWriting(
309  const std::string& extension,
310  const std::string& target = std::string());
311 
312  /// Returns true if the file format for the supplied \p extension and
313  /// \p target pair supports editing.
314  /// This method will not load the plugin that provides the specified
315  /// file format.
316  /// If the extension and target pair is invalid, this method will return
317  /// false.
318  /// \sa FormatSupportsReading \sa FormatSupportsWriting
319  SDF_API
320  static bool FormatSupportsEditing(
321  const std::string& extension,
322  const std::string& target = std::string());
323 
324  /// Returns the file format instance with the specified \p formatId
325  /// identifier. If a format with a matching identifier is not found, this
326  /// returns a null file format pointer.
327  SDF_API
328  static SdfFileFormatConstPtr FindById(
329  const TfToken& formatId);
330 
331  /// Returns the file format instance that supports the extension for
332  /// \p path. If a format with a matching extension is not found, this
333  /// returns a null file format pointer.
334  ///
335  /// An extension may be handled by multiple file formats, but each
336  /// with a different target. In such cases, if no \p target is specified,
337  /// the file format that is registered as the primary plugin will be
338  /// returned. Otherwise, the file format whose target matches \p target
339  /// will be returned.
340  SDF_API
341  static SdfFileFormatConstPtr FindByExtension(
342  const std::string& path,
343  const std::string& target = std::string());
344 
345  /// Returns a file format instance that supports the extension for \p
346  /// path and whose target matches one of those specified by the given
347  /// \p args. If the \p args specify no target, then the file format that is
348  /// registered as the primary plugin will be returned. If a format with a
349  /// matching extension is not found, this returns a null file format
350  /// pointer.
351  SDF_API
352  static SdfFileFormatConstPtr FindByExtension(
353  const std::string& path,
354  const FileFormatArguments& args);
355 
356 protected:
357  /// Constructor.
359  const TfToken& formatId,
360  const TfToken& versionString,
361  const TfToken& target,
362  const std::string& extension);
363 
364  /// Constructor.
365  /// \p schema must remain valid for the lifetime of this file format.
367  const TfToken& formatId,
368  const TfToken& versionString,
369  const TfToken& target,
370  const std::string& extension,
371  const SdfSchemaBase& schema);
372 
373  /// Disallow temporary SdfSchemaBase objects being passed to the c'tor.
375  const TfToken& formatId,
376  const TfToken& versionString,
377  const TfToken& target,
378  const std::string& extension,
379  const SdfSchemaBase&& schema) = delete;
380 
381  /// Constructor.
383  const TfToken& formatId,
384  const TfToken& versionString,
385  const TfToken& target,
386  const std::vector<std::string> &extensions);
387 
388  /// Constructor.
389  /// \p schema must remain valid for the lifetime of this file format.
391  const TfToken& formatId,
392  const TfToken& versionString,
393  const TfToken& target,
394  const std::vector<std::string> &extensions,
395  const SdfSchemaBase& schema);
396 
397  /// Disallow temporary SdfSchemaBase objects being passed to the c'tor.
399  const TfToken& formatId,
400  const TfToken& versionString,
401  const TfToken& target,
402  const std::vector<std::string> &extensions,
403  const SdfSchemaBase&& schema) = delete;
404 
405  /// Destructor.
406  SDF_API virtual ~SdfFileFormat();
407 
408  //
409  // Minimally break layer encapsulation with the following methods. These
410  // methods are also intended to limit the need for SdfLayer friendship with
411  // SdfFileFormat child classes.
412  //
413 
414  /// Set the internal data for \p layer to \p data, possibly transferring
415  /// ownership of \p data.
416  ///
417  /// Existing layer hints are reset to the default hints.
418  SDF_API
419  static void _SetLayerData(
420  SdfLayer* layer, SdfAbstractDataRefPtr& data);
421 
422  /// Set the internal data for \p layer to \p data, possibly transferring
423  /// ownership of \p data.
424  ///
425  /// Existing layer hints are replaced with \p hints.
426  SDF_API
427  static void _SetLayerData(
428  SdfLayer* layer, SdfAbstractDataRefPtr& data,
429  SdfLayerHints hints);
430 
431  /// Get the internal data for \p layer.
432  SDF_API
433  static SdfAbstractDataConstPtr _GetLayerData(const SdfLayer& layer);
434 
435  /// Helper function for _ReadDetached.
436  ///
437  /// Calls Read with the given parameters. If successful and \p layer is
438  /// not detached (i.e., SdfLayer::IsDetached returns false) copies the layer
439  /// data into an SdfData object and set that into \p layer. If this copy
440  /// occurs and \p didCopyData is given, it will be set to true.
441  ///
442  /// Note that the copying process is a simple spec-by-spec, field-by-field
443  /// value copy. This process may not produce detached layers if the data
444  /// object used by \p layer after the initial call to Read returns VtValues
445  /// that are not detached. One example is a VtValue holding a VtArray backed
446  /// by a foreign data source attached to a memory mapping.
447  ///
448  /// Returns true if Read was successful, false otherwise.
449  SDF_API
451  SdfLayer* layer,
452  const std::string& resolvedPath,
453  bool metadataOnly,
454  bool* didCopyData = nullptr) const;
455 
456 protected:
457  SDF_API
459  const SdfFileFormatConstPtr &fileFormat,
460  const std::string &identifier,
461  const std::string &realPath,
462  const ArAssetInfo& assetInfo,
463  const FileFormatArguments &args) const;
464 
465  // File format subclasses may override this if they prefer not to skip
466  // reloading anonymous layers. Default implementation returns true.
467  SDF_API
468  virtual bool _ShouldSkipAnonymousReload() const;
469 
470  /// File format subclasses may override this to specify whether
471  /// Read should be called when creating, opening, or reloading an anonymous
472  /// layer of this format.
473  /// Default implementation returns false.
474  SDF_API
475  virtual bool _ShouldReadAnonymousLayers() const;
476 
477  /// \see InitDetachedData
478  ///
479  /// This function must return a new SdfAbstractData object that is
480  /// detached, i.e. SdfAbstractData::IsDetached returns false.
481  ///
482  /// The default implementation returns an SdfData object.
483  SDF_API
484  virtual SdfAbstractDataRefPtr _InitDetachedData(
485  const FileFormatArguments& args) const;
486 
487  /// \see ReadDetached
488  ///
489  /// Upon completion, \p layer must have an SdfAbstractData object set that
490  /// is detached, i.e. SdfAbstractData::IsDetached returns false.
491  ///
492  /// The default implementation calls _ReadAndCopyLayerDataToMemory to read
493  /// the specified layer and copy its data into an SdfData object if it is
494  /// not detached. If data is copied, a warning will be issued since
495  /// this may be an expensive operation. If the above behavior is desired,
496  /// subclasses can just call _ReadAndCopyLayerDataToMemory to do the same
497  /// thing but without the warning.
498  SDF_API
499  virtual bool _ReadDetached(
500  SdfLayer* layer,
501  const std::string& resolvedPath,
502  bool metadataOnly) const;
503 
504 private:
505  const SdfSchemaBase& _schema;
506  const TfToken _formatId;
507  const TfToken _target;
508  const std::string _cookie;
509  const TfToken _versionString;
510  const std::vector<std::string> _extensions;
511  const bool _isPrimaryFormat;
512 };
513 
514 // Base file format factory.
516 public:
518  virtual SdfFileFormatRefPtr New() const = 0;
519 };
520 
521 // Default file format factory.
522 template <typename T>
524 public:
525  virtual SdfFileFormatRefPtr New() const
526  {
527  return TfCreateRefPtr(new T);
528  }
529 };
530 
531 /// \def SDF_DEFINE_FILE_FORMAT
532 ///
533 /// Performs registrations needed for the specified file format class to be
534 /// discovered by Sdf. This typically would be invoked in a TF_REGISTRY_FUNCTION
535 /// in the source file defining the file format.
536 ///
537 /// The first argument is the name of the file format class being registered.
538 /// Subsequent arguments list the base classes of the file format. Since all
539 /// file formats must ultimately derive from SdfFileFormat, there should be
540 /// at least one base class specified.
541 ///
542 /// For example:
543 ///
544 /// \code
545 /// // in MyFileFormat.cpp
546 /// TF_REGISTRY_FUNCTION(TfType)
547 /// {
548 /// SDF_DEFINE_FILE_FORMAT(MyFileFormat, SdfFileFormat);
549 /// }
550 /// \endcode
551 ///
552 #ifdef doxygen
553 #define SDF_DEFINE_FILE_FORMAT(FileFormatClass, BaseClass1, ...)
554 #else
555 #define SDF_DEFINE_FILE_FORMAT(...) SdfDefineFileFormat<__VA_ARGS__>()
556 
557 template <class FileFormat, class ...BaseFormats>
559 {
560  TfType::Define<FileFormat, TfType::Bases<BaseFormats...>>()
561  .template SetFactory<Sdf_FileFormatFactory<FileFormat>>();
562 }
563 #endif // doxygen
564 
565 /// \def SDF_DEFINE_ABSTRACT_FILE_FORMAT
566 ///
567 /// Performs registrations needed for the specified abstract file format
568 /// class. This is used to register types that serve as base classes
569 /// for other concrete file format classes used by Sdf.
570 ///
571 /// The first argument is the name of the file format class being registered.
572 /// Subsequent arguments list the base classes of the file format. Since all
573 /// file formats must ultimately derive from SdfFileFormat, there should be
574 /// at least one base class specified.
575 ///
576 /// For example:
577 ///
578 /// \code
579 /// // in MyFileFormat.cpp
580 /// TF_REGISTRY_FUNCTION(TfType)
581 /// {
582 /// SDF_DEFINE_ABSTRACT_FILE_FORMAT(MyFileFormat, SdfFileFormat);
583 /// }
584 /// \endcode
585 ///
586 #ifdef doxygen
587 #define SDF_DEFINE_ABSTRACT_FILE_FORMAT(FileFormatClass, BaseClass1, ...)
588 #else
589 #define SDF_DEFINE_ABSTRACT_FILE_FORMAT(...) \
590  SdfDefineAbstractFileFormat<__VA_ARGS__>()
591 
592 template <class FileFormat, class ...BaseFormats>
594 {
595  TfType::Define<FileFormat, TfType::Bases<BaseFormats...>>();
596 }
597 #endif //doxygen
598 
599 /// \def SDF_FILE_FORMAT_FACTORY_ACCESS
600 ///
601 /// Provides access to allow file format classes to be instantiated
602 /// from Sdf. This should be specified in the class definition for
603 /// concrete file format classes.
604 ///
605 /// For example:
606 ///
607 /// \code
608 /// // in MyFileFormat.h
609 /// class MyFileFormat : public SdfFileFormat
610 /// {
611 /// SDF_FILE_FORMAT_FACTORY_ACCESS;
612 /// // ...
613 /// };
614 /// \endcode
615 ///
616 #ifdef doxygen
617 #define SDF_FILE_FORMAT_FACTORY_ACCESS
618 #else
619 #define SDF_FILE_FORMAT_FACTORY_ACCESS \
620  template<typename T> friend class Sdf_FileFormatFactory
621 #endif //doxygen
622 
624 
625 #endif
TfRefPtr< T > TfCreateRefPtr(T *ptr)
Definition: refPtr.h:1223
Definition: layer.h:97
static SDF_API SdfFileFormatConstPtr FindByExtension(const std::string &path, const std::string &target=std::string())
SDF_API const TfToken & GetVersionString() const
Returns the current version of this file format.
virtual SDF_API bool _ReadDetached(SdfLayer *layer, const std::string &resolvedPath, bool metadataOnly) const
SDF_API const std::string & GetFileCookie() const
Returns the cookie to be used when writing files with this format.
TF_DECLARE_PUBLIC_TOKENS(SdfFileFormatTokens, SDF_API, SDF_FILE_FORMAT_TOKENS)
SDF_API bool IsPrimaryFormatForExtensions() const
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
virtual SDF_API bool WriteToFile(const SdfLayer &layer, const std::string &filePath, const std::string &comment=std::string(), const FileFormatArguments &args=FileFormatArguments()) const
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
void SdfDefineAbstractFileFormat()
Definition: fileFormat.h:593
SDF_API bool ReadDetached(SdfLayer *layer, const std::string &resolvedPath, bool metadataOnly) const
Definition: spec.h:49
GLdouble s
Definition: glad.h:3009
SDF_API const TfToken & GetFormatId() const
Returns the format identifier.
SDF_API SdfLayerRefPtr NewLayer(const SdfFileFormatConstPtr &fileFormat, const std::string &identifier, const std::string &realPath, const ArAssetInfo &assetInfo, const FileFormatArguments &args) const
Instantiate a layer.
SdfFileFormat & operator=(const SdfFileFormat &)=delete
virtual SDF_API ~SdfFileFormat()
Destructor.
static SDF_API SdfAbstractDataConstPtr _GetLayerData(const SdfLayer &layer)
Get the internal data for layer.
SDF_API bool _ReadAndCopyLayerDataToMemory(SdfLayer *layer, const std::string &resolvedPath, bool metadataOnly, bool *didCopyData=nullptr) const
virtual SDF_API SdfLayer * _InstantiateNewLayer(const SdfFileFormatConstPtr &fileFormat, const std::string &identifier, const std::string &realPath, const ArAssetInfo &assetInfo, const FileFormatArguments &args) const
static SDF_API bool FormatSupportsWriting(const std::string &extension, const std::string &target=std::string())
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
virtual SDF_API bool WriteToStream(const SdfSpecHandle &spec, std::ostream &out, size_t indent) const
Write the provided spec to out indented indent levels.
Base class of all factory types.
Definition: type.h:73
static SDF_API bool FormatSupportsReading(const std::string &extension, const std::string &target=std::string())
Definition: token.h:87
virtual SdfFileFormatRefPtr New() const =0
SdfFileFormat(const SdfFileFormat &)=delete
static SDF_API SdfFileFormatConstPtr FindById(const TfToken &formatId)
virtual SDF_API bool _ShouldSkipAnonymousReload() const
static TfType const & Define()
Definition: type_Impl.h:77
SDF_API SdfAbstractDataRefPtr InitDetachedData(const FileFormatArguments &args) const
SDF_API const std::vector< std::string > & GetFileExtensions() const
Returns a list of extensions that this format supports.
SDF_API bool ShouldSkipAnonymousReload() const
SDF_API const SdfSchemaBase & GetSchema() const
Returns the schema for this format.
virtual SDF_API bool _ShouldReadAnonymousLayers() const
SDF_API const std::string & GetPrimaryFileExtension() const
virtual SdfFileFormatRefPtr New() const
Definition: fileFormat.h:525
GLenum target
Definition: glcorearb.h:1667
SDF_DECLARE_HANDLES(SdfLayer)
SDF_API bool SupportsReading() const
SDF_API bool IsSupportedExtension(const std::string &extension) const
SDF_API bool SupportsEditing() const
SDF_API const TfToken & GetTarget() const
Returns the target for this file format.
virtual SDF_API bool CanRead(const std::string &file) const =0
Returns true if file can be read by this format.
virtual SDF_API bool IsPackage() const
#define SDF_API
Definition: api.h:40
virtual SDF_API bool Read(SdfLayer *layer, const std::string &resolvedPath, bool metadataOnly) const =0
static SDF_API bool FormatSupportsEditing(const std::string &extension, const std::string &target=std::string())
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
virtual SDF_API SdfAbstractDataRefPtr InitData(const FileFormatArguments &args) const
static SDF_API std::set< std::string > FindAllDerivedFileFormatExtensions(const TfType &baseType)
static SDF_API std::set< std::string > FindAllFileFormatExtensions()
virtual SDF_API ~Sdf_FileFormatFactoryBase()
TF_DECLARE_WEAK_AND_REF_PTRS(SdfAbstractData)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
**If you just want to fire and args
Definition: thread.h:609
Definition: type.h:64
SDF_API bool SupportsWriting() const
virtual SDF_API SdfAbstractDataRefPtr _InitDetachedData(const FileFormatArguments &args) const
virtual SDF_API std::string GetPackageRootLayerPath(const std::string &resolvedPath) const
virtual SDF_API bool WriteToString(const SdfLayer &layer, std::string *str, const std::string &comment=std::string()) const
SDF_API bool ShouldReadAnonymousLayers() const
static SDF_API std::string GetFileExtension(const std::string &s)
virtual SDF_API bool ReadFromString(SdfLayer *layer, const std::string &str) const
#define SDF_FILE_FORMAT_TOKENS
Definition: fileFormat.h:55
static SDF_API void _SetLayerData(SdfLayer *layer, SdfAbstractDataRefPtr &data)
virtual SDF_API FileFormatArguments GetDefaultFileFormatArguments() const
std::map< std::string, std::string > FileFormatArguments
Definition: fileFormat.h:119
OIIO_UTIL_API std::string extension(string_view filepath, bool include_dot=true) noexcept
Definition: format.h:895
virtual SDF_API std::set< std::string > GetExternalAssetDependencies(const SdfLayer &layer) const
void SdfDefineFileFormat()
Definition: fileFormat.h:558