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