Katana Plug-in APIs 0.1

FnAttributeSuite.h

00001 // Copyright (c) 2011 The Foundry Visionmongers Ltd. All Rights Reserved.
00002 
00003 #ifndef FnAttributeSuite_H
00004 #define FnAttributeSuite_H
00005 
00006 #include <stdint.h>
00007 
00008 extern "C" {
00009 
00012 typedef struct FnAttributeStruct * FnAttributeHandle;
00013 
00016 typedef struct FnGroupBuilderStruct * FnGroupBuilderHandle;
00017 
00018 typedef int32_t FnKatAttributeType;
00019 #define kFnKatAttributeTypeNull 0
00020 #define kFnKatAttributeTypeInt 1
00021 #define kFnKatAttributeTypeFloat 2
00022 #define kFnKatAttributeTypeDouble 3
00023 #define kFnKatAttributeTypeString 4
00024 #define kFnKatAttributeTypeGroup 5
00025 #define kFnKatAttributeTypeError -1
00026 
00027 typedef int32_t BuilderModeType;
00028 #define kFnKatGroupBuilderModeNormal 0
00029 #define kFnKatGroupBuilderModeStrict 1
00030 
00031 typedef int32_t BuilderBuildMode;
00032 #define kFnKatGroupBuilderBuildAndFlush  0
00033 #define kFnKatGroupBuilderBuildAndRetain 1
00034 
00035 typedef int32_t FnKatStreamType;
00036 #define kFnKatStreamTypeBinary 0
00037 #define kFnKatStreamTypeXML 1
00038 
00039 struct FnAttributeHash
00040 {
00041     uint64_t hash1;
00042     uint64_t hash2;
00043 };
00044 
00048 typedef int64_t (*FnAttributeWriteStreamFunc)(void *stream, const void *buf, int64_t size);
00049 
00053 typedef int64_t (*FnAttributeReadStreamFunc)(void *stream, void *buf, int64_t size);
00054 
00058 typedef void (*FnAttributeFreeOwnedDataFunc)(void* context);
00059 
00060 enum
00061 {
00070     kFnKatAttributeSampleAccessorRefCounted = 0x1u,
00071 
00079     kFnKatAttributeSampleAccessorContiguous = 0x10u,
00080 
00088     kFnKatAttributeSampleAccessorIndirected = 0x20u,
00089 };
00090 typedef uint32_t FnKatAttributeSampleAccessorOptions;
00091 
00094 typedef struct FnAttributeSampleAccessorStorage
00095 {
00097     int version;
00099     FnKatAttributeSampleAccessorOptions options;
00101     int64_t sampleCount;
00103     int64_t valueCount;
00106     const float* sampleTimes;
00107     union
00108     {
00114         const void* values;
00115 
00122         const void* const* samples;
00123     };
00125     uintptr_t opaque[3];
00126 } FnAttributeSampleAccessor;
00127 
00128 
00138 struct FnAttributeHostSuite
00139 {
00140     // All Attrs
00141     // TODO remove streamType and auto determine it when we can
00142     FnAttributeHandle (*readAttributeStream)(void *stream,
00143         FnAttributeReadStreamFunc func,
00144         FnAttributeHandle *errorMessage,
00145         FnKatStreamType streamType);
00146 
00147     uint8_t (*writeAttributeStream)(FnAttributeHandle handle,
00148         void *stream, FnAttributeWriteStreamFunc func,
00149         FnAttributeHandle *errorMessage,
00150         FnKatStreamType streamType);
00151 
00152     FnKatAttributeType (*getType)(FnAttributeHandle handle);
00153     void (*retainAttr)(FnAttributeHandle handle);
00154     void (*releaseAttr)(FnAttributeHandle handle);
00155     uint8_t (*isEqual)(FnAttributeHandle handle, FnAttributeHandle otherHandle);
00156     FnAttributeHash (*getHash)(FnAttributeHandle handle);
00157 
00158     // DataAttrs
00159     int64_t (*getTupleSize)(FnAttributeHandle handle);
00160     int64_t (*getNumberOfValues)(FnAttributeHandle handle);
00161     int64_t (*getNumberOfTuples)(FnAttributeHandle handle);
00162     int64_t (*getNumberOfTimeSamples)(FnAttributeHandle handle);
00163     float (*getSampleTime)(FnAttributeHandle handle, int64_t index);
00164     uint8_t (*getBoundingSampleTimes)(FnAttributeHandle handle,
00165         float *ltime, float *rtime, float time);
00166 
00167     // NullAttr
00168     FnAttributeHandle (*createNullAttr)();
00169 
00170     // IntAttr
00171     FnAttributeHandle (*createIntAttr0)();
00172     FnAttributeHandle (*createIntAttr1)(int32_t value);
00173     FnAttributeHandle (*createIntAttr2)(const int32_t *values, int64_t valueCount,
00174         int64_t tupleSize);
00175     FnAttributeHandle (*createIntAttr3)(const float *times, int64_t timeCount,
00176         const int32_t **values, int64_t valueCount, int64_t tupleSize);
00177     const int32_t *(*getIntNearestSample)(FnAttributeHandle handle, float time,
00178         int64_t *valueCount);
00179 
00180     // FloatAttr
00181     FnAttributeHandle (*createFloatAttr0)();
00182     FnAttributeHandle (*createFloatAttr1)(float value);
00183     FnAttributeHandle (*createFloatAttr2)(const float *values, int64_t valueCount,
00184         int64_t tupleSize);
00185     FnAttributeHandle (*createFloatAttr3)(const float *times, int64_t timeCount,
00186         const float **values, int64_t valueCount, int64_t tupleSize);
00187     const float *(*getFloatNearestSample)(FnAttributeHandle handle, float time,
00188         int64_t *valueCount);
00189 
00190     // DoubleAttr
00191     FnAttributeHandle (*createDoubleAttr0)();
00192     FnAttributeHandle (*createDoubleAttr1)(double value);
00193     FnAttributeHandle (*createDoubleAttr2)(const double *values, int64_t valueCount,
00194         int64_t tupleSize);
00195     FnAttributeHandle (*createDoubleAttr3)(const float *times, int64_t timeCount,
00196         const double **values, int64_t valueCount, int64_t tupleSize);
00197     const double *(*getDoubleNearestSample)(FnAttributeHandle handle,
00198         float time, int64_t *valueCount);
00199 
00200     // StringAttr
00201     FnAttributeHandle (*createStringAttr0)();
00202     FnAttributeHandle (*createStringAttr1)(const char *value);
00203     FnAttributeHandle (*createStringAttr2)(const char **values, int64_t valueCount,
00204         int64_t tupleSize);
00205     FnAttributeHandle (*createStringAttr3)(const float *times, int64_t timeCount,
00206         const char ***values, int64_t valueCount, int64_t tupleSize);
00207     const char **(*getStringNearestSample)(FnAttributeHandle handle, float time,
00208         int64_t *valueCount);
00209 
00210     // GroupAttr
00211     FnAttributeHandle (*createGroupAttr)(const char **names,
00212         FnAttributeHandle *children, int64_t childCount, uint8_t groupInherit);
00213     int64_t (*getNumberOfChildren)(FnAttributeHandle handle);
00214     const char *(*getChildNameByIndex)(FnAttributeHandle, int64_t index,
00215         int32_t * nameSize);
00216     FnAttributeHandle (*getChildByIndex)(FnAttributeHandle handle,
00217         int64_t index);
00218     FnAttributeHandle (*getChildByName)(FnAttributeHandle handle,
00219         const char *name, int32_t stringlen);
00220     uint8_t (*getGroupInherit)(FnAttributeHandle handle);
00221 
00222     // GroupBuilder
00223     FnGroupBuilderHandle (*createGroupBuilder)();
00224     FnGroupBuilderHandle (*createGroupBuilder2)(BuilderModeType builderMode);
00225     void (*releaseGroupBuilder)(FnGroupBuilderHandle handle);
00226     void (*setGroupBuilder)(FnGroupBuilderHandle handle, const char *path,
00227         int32_t stringlen, FnAttributeHandle attr, uint8_t groupInherit);
00228     void (*setGroupBuilderUnique)(FnGroupBuilderHandle handle, const char *path,
00229         int32_t stringlen, FnAttributeHandle attr, uint8_t groupInherit);
00230     void (*delGroupBuilder)(FnGroupBuilderHandle handle, const char *path,
00231         int32_t stringlen);
00232     void (*updateGroupBuilder)(FnGroupBuilderHandle handle,
00233         FnAttributeHandle attr);
00234     void (*deepUpdateGroupBuilder)(FnGroupBuilderHandle handle,
00235         FnAttributeHandle attr);
00236     void (*reserveGroupBuilder)(FnGroupBuilderHandle handle, int64_t n);
00237     FnAttributeHandle (*buildGroupBuilder)(FnGroupBuilderHandle handle,
00238         BuilderBuildMode buildMode);
00239     void (*setGroupBuilderInherit)(FnGroupBuilderHandle handle,
00240         uint8_t groupInherit);
00241     void (*sortGroupBuilder)(FnGroupBuilderHandle handle);
00242 
00243     // Name Utils
00244     // Currently swaps '.' and '/' to non-ambiguous alternatives
00245     void (*delimiterEncode)(char * str, uint64_t len);
00246     void (*delimiterDecode)(char * str, uint64_t len);
00247 
00248     // GetValue
00249     uint8_t (*getIntValue)(FnAttributeHandle* phandle, float time,
00250         int64_t index, int32_t* valueOut);
00251     uint8_t (*getFloatValue)(FnAttributeHandle* phandle, float time,
00252         int64_t index, float* valueOut);
00253     uint8_t (*getDoubleValue)(FnAttributeHandle* phandle, float time,
00254         int64_t index, double* valueOut);
00255     uint8_t (*getStringValue)(FnAttributeHandle* phandle, float time,
00256         int64_t index, const char** valueOut);
00257 
00274     void (*disableRefCounting)(FnAttributeHandle handle);
00275 
00280     uint8_t (*isRefCounted)(FnAttributeHandle handle);
00281 
00290     void (*dispose)(FnAttributeHandle handle);
00291 
00303     FnAttributeSampleAccessor* (*createAccessor)(
00304         FnAttributeHandle attr,
00305         FnKatAttributeType type,
00306         FnKatAttributeSampleAccessorOptions options,
00307         struct FnAttributeSampleAccessorStorage* storage);
00308 
00315     void (*retainAccessor)(FnAttributeSampleAccessor* accessor);
00316 
00323     void (*releaseAccessor)(FnAttributeSampleAccessor* accessor);
00324 
00357     FnAttributeHandle (*createIntAttrFactory)(
00358         const float* times,
00359         int64_t timeCount,
00360         const int32_t** values,
00361         int64_t valueCount,
00362         int64_t tupleSize,
00363         void* context,
00364         FnAttributeFreeOwnedDataFunc freeOwnedDataFunc);
00365 
00398     FnAttributeHandle (*createFloatAttrFactory)(
00399         const float* times,
00400         int64_t timeCount,
00401         const float** values,
00402         int64_t valueCount,
00403         int64_t tupleSize,
00404         void* context,
00405         FnAttributeFreeOwnedDataFunc freeOwnedDataFunc);
00406 
00439     FnAttributeHandle (*createDoubleAttrFactory)(
00440         const float* times,
00441         int64_t timeCount,
00442         const double** values,
00443         int64_t valueCount,
00444         int64_t tupleSize,
00445         void* context,
00446         FnAttributeFreeOwnedDataFunc freeOwnedDataFunc);
00447 
00480     FnAttributeHandle (*createStringAttrFactory)(
00481         const float* times,
00482         int64_t timeCount,
00483         const char*** values,
00484         int64_t valueCount,
00485         int64_t tupleSize,
00486         void* context,
00487         FnAttributeFreeOwnedDataFunc freeOwnedDataFunc);
00488 
00508     uint64_t (*getSize)(FnAttributeHandle handle);
00509 
00513     uint64_t (*getTotalSize)();
00514 };
00515 
00516 // Declaration of the default suite version.
00517 #define FnAttributeHostSuite_version                      5
00518 #define FnGetAttributeHostSuite  FnGetAttributeHostSuite_v5
00519 
00520 }
00521 #endif // FnAttributeSuite_H
 All Classes Functions Variables Typedefs Enumerations Enumerator