| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #ifndef O3D_IMPORT_CROSS_RAW_DATA_H_ | 39 #ifndef O3D_IMPORT_CROSS_RAW_DATA_H_ |
| 40 #define O3D_IMPORT_CROSS_RAW_DATA_H_ | 40 #define O3D_IMPORT_CROSS_RAW_DATA_H_ |
| 41 | 41 |
| 42 #include "base/file_path.h" | 42 #include "base/file_path.h" |
| 43 #include "base/scoped_ptr.h" | 43 #include "base/scoped_ptr.h" |
| 44 #include "core/cross/error.h" | 44 #include "core/cross/error.h" |
| 45 #include "core/cross/param_object.h" | 45 #include "core/cross/param_object.h" |
| 46 #include "core/cross/param.h" | 46 #include "core/cross/param.h" |
| 47 #include "core/cross/types.h" | 47 #include "core/cross/types.h" |
| 48 | 48 |
| 49 class FilePath; |
| 50 |
| 49 namespace o3d { | 51 namespace o3d { |
| 50 | 52 |
| 51 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 53 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 52 class RawData : public ParamObject { | 54 class RawData : public ParamObject { |
| 53 public: | 55 public: |
| 54 typedef SmartPointer<RawData> Ref; | 56 typedef SmartPointer<RawData> Ref; |
| 55 | 57 |
| 56 static RawData::Ref Create(ServiceLocator* service_locator, | 58 static RawData::Ref Create(ServiceLocator* service_locator, |
| 57 const String &uri, | 59 const String &uri, |
| 58 const void *data, | 60 const void *data, |
| 59 size_t length); | 61 size_t length); |
| 60 | 62 |
| 63 static RawData::Ref CreateFromFile(ServiceLocator* service_locator, |
| 64 const String &uri, |
| 65 const String& filename); |
| 66 |
| 61 virtual ~RawData(); | 67 virtual ~RawData(); |
| 62 | 68 |
| 63 const uint8 *GetData() const; | 69 const uint8 *GetData() const; |
| 64 | 70 |
| 65 template <typename T> | 71 template <typename T> |
| 66 const T* GetDataAs(size_t offset) const { | 72 const T* GetDataAs(size_t offset) const { |
| 67 return reinterpret_cast<const T*>(GetData() + offset); | 73 return reinterpret_cast<const T*>(GetData() + offset); |
| 68 }; | 74 }; |
| 69 | 75 |
| 70 size_t GetLength() const { return length_; } | 76 size_t GetLength() const { return length_; } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 96 FilePath temp_filepath_; | 102 FilePath temp_filepath_; |
| 97 | 103 |
| 98 // Deletes temp file if it exists | 104 // Deletes temp file if it exists |
| 99 void DeleteTempFile(); | 105 void DeleteTempFile(); |
| 100 | 106 |
| 101 RawData(ServiceLocator* service_locator, | 107 RawData(ServiceLocator* service_locator, |
| 102 const String &uri, | 108 const String &uri, |
| 103 const void *data, | 109 const void *data, |
| 104 size_t length); | 110 size_t length); |
| 105 | 111 |
| 112 bool SetFromFile(const String& filename); |
| 113 |
| 106 friend class IClassManager; | 114 friend class IClassManager; |
| 107 friend class Pack; | 115 friend class Pack; |
| 108 | 116 |
| 109 // Returns |true| on success | 117 // Returns |true| on success |
| 110 bool GetTempFilePathFromURI(const String &uri, | 118 bool GetTempFilePathFromURI(const String &uri, |
| 111 FilePath *temp_fullpath); | 119 FilePath *temp_fullpath); |
| 112 | 120 |
| 113 O3D_DECL_CLASS(RawData, ParamObject) | 121 O3D_DECL_CLASS(RawData, ParamObject) |
| 114 DISALLOW_COPY_AND_ASSIGN(RawData); | 122 DISALLOW_COPY_AND_ASSIGN(RawData); |
| 115 }; | 123 }; |
| 116 | 124 |
| 117 } // namespace o3d | 125 } // namespace o3d |
| 118 | 126 |
| 119 #endif // O3D_IMPORT_CROSS_RAW_DATA_H_ | 127 #endif // O3D_IMPORT_CROSS_RAW_DATA_H_ |
| OLD | NEW |