- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# FUtils/FUError.h

Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 2005-2007 Feeling Software Inc.
    00003     Portions of the code are:
    00004     Copyright (C) 2005-2007 Sony Computer Entertainment America
    00005
    00006     MIT License: http://www.opensource.org/licenses/mit-license.php
    00007 */
    00008
    00014 #ifndef _FU_ERROR_H_
    00015 #define _FU_ERROR_H_
    00016
    00017 #ifndef _FU_EVENT_H_
    00018 #include "FUtils/FUEvent.h"
    00019 #endif // _FU_EVENT_H_
    00020 #ifndef _FU_CRITICAL_SECTION_H_
    00021 #include "FUtils/FUCriticalSection.h"
    00022 #endif // _FU_CRITICAL_SECTION_H_
    00023
    00025 #undef ERROR
    00026
    00033 class FCOLLADA_EXPORT FUError
    00034 {
    00035 public:
    00039     enum Code
    00040     {
    00041         //
    00042         // Errors
    00043         //
    00044         ERROR_DEFAULT_ERROR = 0, ERROR_MALFORMED_XML, ERROR_PARSING_FAILED, ERROR_INVALID_ELEMENT, ERROR_MISSING_ELEMENT, /*[0, 4]*/
    00045         ERROR_UNKNOWN_ELEMENT, ERROR_MISSING_INPUT, ERROR_INVALID_URI, ERROR_WRITE_FILE, ERROR_MISSING_PROPERTY, /*[5, 9]*/
    00046         NO_MATCHING_PLUGIN,
    00047
    00048         ERROR_ANIM_CURVE_DRIVER_MISSING,
    00049         ERROR_SOURCE_SIZE,
    00050         ERROR_IB_MATRIX_MISSING,
    00051         ERROR_VCOUNT_MISSING,
    00052         ERROR_V_ELEMENT_MISSING,
    00053         ERROR_JC_BPMC_NOT_EQUAL,
    00054         ERROR_INVALID_VCOUNT,
    00055         ERROR_PARSING_PROG_ERROR,
    00056         ERROR_UNKNOWN_CHILD,
    00057         ERROR_UNKNOWN_GEO_CH,
    00058         ERROR_UNKNOWN_MESH_ID,
    00059         ERROR_INVALID_U_KNOT,
    00060         ERROR_INVALID_V_KNOT,
    00061         ERROR_NOT_ENOUGHT_V_KNOT,
    00062         ERROR_NOT_ENOUGHT_U_KNOT,
    00063         ERROR_INVALID_CONTROL_VERTICES,
    00064         ERROR_NO_CONTROL_VERTICES,
    00065         ERROR_UNKNOWN_POLYGONS,
    00066         WARNING_NO_POLYGON,
    00067         ERROR_NO_VERTEX_INPUT,
    00068         ERROR_NO_VCOUNT,
    00069         ERROR_MISPLACED_VCOUNT,
    00070         ERROR_UNKNOWN_PH_ELEMENT,
    00071         ERROR_INVALID_FACE_COUNT,
    00072         ERROR_DUPLICATE_ID,
    00073         ERROR_INVALID_CVS_WEIGHTS,
    00074         ERROR_INVALID_SPLINE,
    00075         ERROR_UNKNOWN_EFFECT_CODE,
    00076         ERROR_BAD_FLOAT_VALUE,
    00077         ERROR_BAD_BOOLEAN_VALUE,
    00078         ERROR_BAD_FLOAT_PARAM,
    00079         ERROR_BAD_FLOAT_PARAM2,
    00080         ERROR_BAD_FLOAT_PARAM3,
    00081         ERROR_BAD_FLOAT_PARAM4,
    00082         ERROR_BAD_MATRIX,
    00083         ERROR_PROG_NODE_MISSING,
    00084         ERROR_INVALID_TEXTURE_SAMPLER,
    00085         ERROR_PARAM_NODE_MISSING,
    00086         ERROR_INVALID_IMAGE_FILENAME,
    00087         ERROR_UNKNOWN_TEXTURE_SAMPLER,
    00088         ERROR_COMMON_TECHNIQUE_MISSING,
    00089         ERROR_TECHNIQUE_NODE_MISSING,
    00090         ERROR_PHYSICS_MODEL_CYCLE_DETECTED,
    00091
    00092         // max only errors
    00093         ERROR_MAX_CANNOT_RESIZE_MUT_LIST,
    00094
    00095         //
    00096         //Warnings
    00097         //
    00098         WARNING_UNSUPPORTED_TEXTURE_UVS,
    00099
    00100         // Warnings
    00101         WARNING_MISSING_URI_TARGET,
    00102         WARNING_UNKNOWN_CHILD_ELEMENT,
    00103         WARNING_UNKNOWN_AC_CHILD_ELEMENT,
    00104         WARNING_BASE_NODE_TYPE,
    00105         WARNING_INST_ENTITY_MISSING,
    00106         WARNING_INVALID_MATERIAL_BINDING,
    00107         WARNING_UNKNOWN_MAT_ID,
    00108         WARNING_RIGID_CONSTRAINT_MISSING,
    00109         WARNING_INVALID_ANIM_LIB,
    00110         WARNING_INVALID_ANIM_TARGET,
    00111         WARNING_UNKNOWN_ANIM_LIB_ELEMENT,
    00112         WARNING_INVALID_SE_PAIR,
    00113         WARNING_CURVES_MISSING,
    00114         WARNING_EMPTY_ANIM_CLIP,
    00115         WARNING_UNKNOWN_CAM_ELEMENT,
    00116         WARNING_NO_STD_PROG_TYPE,
    00117         WARNING_PARAM_ROOT_MISSING,
    00118         WARNING_UNKNOWN_CAM_PROG_TYPE,
    00119         WARNING_UNKNOWN_CAM_PARAM,
    00120         WARNING_UNKNOWN_LIGHT_LIB_ELEMENT,
    00121         WARNING_UNKNOWN_LIGHT_TYPE_VALUE,
    00122         WARNING_UNKNOWN_LT_ELEMENT,
    00123         WARNING_UNKNOWN_LIGHT_PROG_PARAM,
    00124         WARNING_INVALID_CONTROLLER_LIB_NODE,
    00125         WARNING_CONTROLLER_TYPE_CONFLICT,
    00126         WARNING_SM_BASE_MISSING,
    00127         WARNING_UNKNOWN_MC_PROC_METHOD,
    00128         WARNING_UNKNOWN_MC_BASE_TARGET_MISSING,
    00129         WARNING_UNKNOWN_MORPH_TARGET_TYPE,
    00130         WARNING_TARGET_GEOMETRY_MISSING,
    00131         WARNING_CONTROLLER_TARGET_MISSING,
    00132         WARNING_UNKNOWN_SC_VERTEX_INPUT,
    00133         WARNING_INVALID_TARGET_GEOMETRY_OP,
    00134         WARNING_INVALID_JOINT_INDEX,
    00135         WARNING_INVALID_WEIGHT_INDEX,
    00136         WARNING_UNKNOWN_JOINT,
    00137         WARNING_UNKNOWN_GL_ELEMENT,
    00138         WARNING_EMPTY_GEOMETRY,
    00139         WARNING_MESH_VERTICES_MISSING,
    00140         WARNING_VP_INPUT_NODE_MISSING,
    00141         WARNING_GEOMETRY_VERTICES_MISSING,
    00142         WARNING_MESH_TESSELLATION_MISSING,
    00143         WARNING_INVALID_POLYGON_MAT_SYMBOL,
    00144         WARNING_EXTRA_VERTEX_INPUT,
    00145         WARNING_UNKNOWN_POLYGONS_INPUT,
    00146         WARNING_UNKNOWN_POLYGON_CHILD,
    00147         WARNING_INVALID_PRIMITIVE_COUNT,
    00148         WARNING_INVALID_GEOMETRY_SOURCE_ID,
    00149         WARNING_EMPTY_SOURCE,
    00150         WARNING_EMPTY_POLYGONS,
    00151         WARNING_SPLINE_CONTROL_INPUT_MISSING,
    00152         WARNING_CONTROL_VERTICES_MISSING,
    00153         WARNING_VARYING_SPLINE_TYPE,
    00154         WARNING_UNKNOWN_EFFECT_ELEMENT,
    00155         WARNING_UNSUPPORTED_PROFILE,
    00156         WARNING_SID_MISSING,
    00157         WARNING_INVALID_ANNO_TYPE,
    00158         WARNING_GEN_REF_ATTRIBUTE_MISSING,
    00159         WARNING_MOD_REF_ATTRIBUTE_MISSING,
    00160         WARNING_SAMPLER_NODE_MISSING,
    00161         WARNING_EMPTY_SURFACE_SOURCE,
    00162         WARNING_EMPTY_INIT_FROM,
    00163         WARNING_EMPTY_IMAGE_NAME,
    00164         WARNING_UNKNOWN_PASS_ELEMENT,
    00165         WARNING_UNKNOWN_PASS_SHADER_ELEMENT,
    00166         WARNING_UNAMED_EFFECT_PASS_SHADER,
    00167         WARNING_UNKNOWN_EPS_STAGE,
    00168         WARNING_INVALID_PROFILE_INPUT_NODE,
    00169         WARNING_UNKNOWN_STD_MAT_BASE_ELEMENT,
    00170         WARNING_TECHNIQUE_MISSING,
    00171         WARNING_UNKNOWN_MAT_INPUT_SEMANTIC,
    00172         WARNING_UNKNOWN_INPUT_TEXTURE,
    00173         WARNING_UNSUPPORTED_SHADER_TYPE,
    00174         WARNING_UNKNOWN_MAT_PARAM_NAME,
    00175         WARNING_UNKNOWN_TECHNIQUE_ELEMENT,
    00176         WARNING_UNKNOWN_IMAGE_LIB_ELEMENT,
    00177         WARNING_UNKNOWN_TEX_LIB_ELEMENT,
    00178         WARNING_UNKNOWN_CHANNEL_USAGE,
    00179         WARNING_UNKNOWN_INPUTE_SEMANTIC,
    00180         WARNING_UNKNOWN_IMAGE_SOURCE,
    00181         WARNING_UNKNOWN_MAT_LIB_ELEMENT,
    00182         WARNING_UNSUPPORTED_REF_EFFECTS,
    00183         WARNING_EMPTY_INSTANCE_EFFECT,
    00184         WARNING_EFFECT_MISSING,
    00185         WARNING_UNKNOWN_FORCE_FIELD_ELEMENT,
    00186         WARNING_UNKNOWN_ELEMENT,
    00187         WARNING_INVALID_BOX_TYPE,
    00188         WARNING_INVALID_PLANE_TYPE,
    00189         WARNING_INVALID_SPHERE_TYPE,
    00190         WARNING_INVALID_CAPSULE_TYPE,
    00191         WARNING_INVALID_TCAPSULE_TYPE,
    00192         WARNING_INVALID_TCYLINDER_TYPE,
    00193         WARNING_UNKNOWN_PHYS_MAT_LIB_ELEMENT,
    00194         WARNING_UNKNOWN_PHYS_LIB_ELEMENT,
    00195         WARNING_CORRUPTED_INSTANCE,
    00196         WARNING_UNKNOWN_PRB_LIB_ELEMENT,
    00197         WARNING_PHYS_MAT_INST_MISSING,
    00198         WARNING_PHYS_MAT_DEF_MISSING,
    00199         WARNING_UNKNOWN_RGC_LIB_ELEMENT,
    00200         WARNING_INVALID_NODE_TRANSFORM,
    00201         WARNING_RF_NODE_MISSING,
    00202         WARNING_RF_REF_NODE_MISSING,
    00203         WARNING_TARGET_BS_NODE_MISSING,
    00204         WARNING_TARGE_BS_REF_NODE_MISSING,
    00205         WARNING_UNKNOW_PS_LIB_ELEMENT,
    00206         WARNING_FCDGEOMETRY_INST_MISSING,
    00207         WARNING_INVALID_SHAPE_NODE,
    00208         WARNING_SHAPE_NODE_MISSING,
    00209         WARNING_UNKNOW_NODE_ELEMENT_TYPE,
    00210         WARNING_CYCLE_DETECTED,
    00211         WARNING_INVALID_NODE_INST,
    00212         WARNING_INVALID_WEAK_NODE_INST,
    00213         WARNING_UNSUPPORTED_EXTERN_REF,
    00214         WARNING_UNEXPECTED_ASSET,
    00215         WARNING_INVALID_TRANSFORM,
    00216         WARNING_TARGET_SCENE_NODE_MISSING,
    00217         WARNING_UNSUPPORTED_EXTERN_REF_NODE,
    00218         WARNING_XREF_UNASSIGNED,
    00219         WARNING_MASS_AND_DENSITY_MISSING,
    00220
    00221         //
    00222         //Debug
    00223         //
    00224         DEBUG_LOAD_SUCCESSFUL,
    00225         DEBUG_WRITE_SUCCESSFUL,
    00226
    00227         ERROR_CUSTOM_STRING = 5000
    00228     };
    00229
    00233     enum Level
    00234     {
    00235         DEBUG_LEVEL = 0,
    00236         WARNING_LEVEL = 1,
    00237         ERROR_LEVEL = 2,
    00238
    00239         LEVEL_COUNT
    00240     };
    00241
    00243     typedef IFunctor3<FUError::Level, uint32, uint32, void> FUErrorFunctor;
    00244
    00245 private:
    00246     static FUCriticalSection criticalSection;
    00247     static FUEvent3<FUError::Level, uint32, uint32> onErrorEvent;
    00248     static FUEvent3<FUError::Level, uint32, uint32> onWarningEvent;
    00249     static FUEvent3<FUError::Level, uint32, uint32> onDebugEvent;
    00250     static fm::string customErrorString;
    00251     static FUError::Level fatalLevel;
    00252
    00253     // This class is not meant to be constructed.
    00254     FUError();
    00255     ~FUError();
    00256
    00257 public:
    00264     static bool Error(FUError::Level errorLevel, uint32 errorCode, uint32 line = 0);
    00265
    00269     static void AddErrorCallback(FUError::Level errorLevel, FUErrorFunctor* callback);
    00270
    00275     template <class Class>
    00276     static void AddErrorCallback(FUError::Level errorLevel, Class* handle, void (Class::*_function)(FUError::Level, uint32, uint32))
    00277     {
    00278         AddErrorCallback(errorLevel, new FUFunctor3<Class, FUError::Level, uint32, uint32, void>(handle, _function));
    00279     }
    00280
    00284     static void AddErrorCallback(FUError::Level errorLevel, void (*_function)(FUError::Level, uint32, uint32))
    00285     {
    00286         AddErrorCallback(errorLevel, new FUStaticFunctor3<FUError::Level, uint32, uint32, void>(_function));
    00287     }
    00288
    00293     static void RemoveErrorCallback(FUError::Level errorLevel, void* object, void* function);
    00294
    00299     template <class Class>
    00300     static void RemoveErrorCallback(FUError::Level errorLevel, Class* handle, void (Class::*_function)(FUError::Level, uint32, uint32))
    00301     {
    00302         void* function = *(void**)(size_t)&_function;
    00303         RemoveErrorCallback(errorLevel, (void*) handle, function);
    00304     }
    00305
    00309     static void RemoveErrorCallback(FUError::Level errorLevel, void (*_function)(FUError::Level, uint32, uint32))
    00310     {
    00311         void* function = *(void**)(size_t)&_function;
    00312         RemoveErrorCallback(errorLevel, NULL, function);
    00313     }
    00314
    00318     static const char* GetErrorString(FUError::Code errorCode);
    00319
    00324     static void SetCustomErrorString(const char* customErrorString);
    00325
    00328     static FUError::Level GetFatalityLevel() { return fatalLevel; }
    00329
    00332     static void SetFatalityLevel(FUError::Level _fatalLevel) { fatalLevel = _fatalLevel; }
    00333 };
    00334
    00341 class FCOLLADA_EXPORT FUErrorSimpleHandler
    00342 {
    00343 private:
    00344     FUSStringBuilder message;
    00345     FUError::Level localFatalityLevel;
    00346     bool fails;
    00347
    00348 public:
    00352     FUErrorSimpleHandler(FUError::Level fatalLevel = FUError::ERROR_LEVEL);
    00353
    00355     ~FUErrorSimpleHandler();
    00356
    00362     inline const char* GetErrorString() const { return message.ToCharPtr(); }
    00363
    00366     inline bool IsSuccessful() const { return !fails; }
    00367
    00368 private:
    00369     void OnError(FUError::Level errorLevel, uint32 errorCode, uint32 lineNumber);
    00370 };
    00371
    00372 #endif // _FU_ERROR_H_