Cortex  10.0.0-a4
Reader.h
1 //
3 // Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // * Neither the name of Image Engine Design nor the names of any
17 // other contributors to this software may be used to endorse or
18 // promote products derived from this software without specific prior
19 // written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
34 
35 #ifndef IE_CORE_READER_H
36 #define IE_CORE_READER_H
37 
38 #include <map>
39 #include <vector>
40 
41 #include "boost/function.hpp"
42 
43 #include "IECore/Export.h"
44 #include "IECore/Op.h"
45 #include "IECore/CompoundObject.h"
46 
47 namespace IECore
48 {
49 
50 IE_CORE_FORWARDDECLARE( Reader );
51 IE_CORE_FORWARDDECLARE( FileNameParameter );
52 
56 class IECORE_API Reader : public Op
57 {
58 
59  public :
60 
61  IE_CORE_DECLARERUNTIMETYPED( Reader, Op );
62 
66  const std::string &fileName() const;
67 
73  virtual CompoundObjectPtr readHeader();
74 
79  ObjectPtr read();
80 
83 
84  static ReaderPtr create( const std::string &fileName );
87 
90  static void supportedExtensions( std::vector<std::string> &extensions );
91 
94  static void supportedExtensions( TypeId typeId, std::vector<std::string> &extensions );
95 
98  typedef boost::function<ReaderPtr ( const std::string &fileName )> CreatorFn;
101  typedef boost::function<bool ( const std::string &fileName )> CanReadFn;
102 
110  static void registerReader( const std::string &extensions, CanReadFn canRead, CreatorFn creator, TypeId typeId );
112 
113  protected :
114 
119  Reader( const std::string &description, ParameterPtr resultParameter = nullptr );
120 
127  template<class T>
129  {
130  public :
131  ReaderDescription( const std::string &extensions );
132  private :
133  static ReaderPtr creator( const std::string &fileName );
134  };
135 
136  FileNameParameterPtr m_fileNameParameter;
137 
138  private :
139 
140  struct ReaderFns
141  {
142  CreatorFn creator;
143  CanReadFn canRead;
144  TypeId typeId;
145  };
146  typedef std::multimap<std::string, ReaderFns> ExtensionsToFnsMap;
147  static ExtensionsToFnsMap *extensionsToFns();
148 
149 };
150 
151 } // namespace IECore
152 
153 #include "IECore/Reader.inl"
154 
155 #endif // IE_CORE_READER_H
Definition: Op.h:53
Definition: Reader.h:56
boost::function< ReaderPtr(const std::string &fileName)> CreatorFn
Definition: Reader.h:98
TypeId
Definition: TypeIds.h:46
Definition: Reader.h:128
boost::function< bool(const std::string &fileName)> CanReadFn
Definition: Reader.h:101
This namespace contains all components of the core library.
Definition: AddSmoothSkinningInfluencesOp.h:43