//////////////////////////////////////////////////////////////////////////////
//
//  Copyright 2025 Autodesk, Inc.  All rights reserved.
//
//  Use of this software is subject to the terms of the Autodesk license 
//  agreement provided at the time of installation or download, or which 
//  otherwise accompanies this software in either electronic or hard copy form.   
//
//////////////////////////////////////////////////////////////////////////////

// DESCRIPTION: This file contains the enums and definitions for
//
#ifndef AMISTATUS_H
#define AMISTATUS_H

#include "adesk.h"               // Adesk name space
#include "acadstrc.h"            // Acad::ErrorStatus
#include "attr.h"                // Attr name space
#include "mitstdstring.h"        // TSTDSTRING 

#include <string>
#ifdef DEBUG_WAS_ON_IN_MISTATUS
#define _DEBUG
#undef DEBUG_WAS_ON_IN_MISTATUS
#endif

#ifdef MCADAPIBUILD
    #define AMIAPI __declspec(dllexport)
#else
    #define AMIAPI __declspec(dllimport)
#endif

#define MCADAPI_DECLARE_MEMBERS(name) \
        protected:                    \
          virtual ~name() {}          \
        public:                       \
          ACRX_DECLARE_MEMBERS(name)

#define Designer_Assemblies ACRX_T(/*MSG0*/"Designer_Assemblies")

typedef long AmiFuncId;

typedef long AmiAppId;

class AmiStatus;

#define AMIFIRSTSTATUSCODEVAL 2001

namespace Ami
{
    ///<summary>Enumeration of severities for AmiStatus.</summary>
    enum Severity
    {
        kInfo       = 0x0,
        kWarning    = 0x1,
        kError      = 0x2,
        kSevere     = 0x3
    };

    ///<summary>Enumeration of status codes for AmiStatus. Using values in the range 2001-3000.</summary>
    enum StatusCode
    {
        ///<summary>situation normal</summary>
        kOk              = 0,           // situation normal
        kNotApplicable   = AMIFIRSTSTATUSCODEVAL,   // op N/A to args
        kMakeMeProxy,                   // for dwgInFields()
        kInternalUnsupported,
        kInternalFailure,
        kInvalidArg,
        kNotCurrentDoc,
        kNoDocument,
        ///<summary>required database is unloaded</summary>
        kDatabaseUnloaded,              // required database is unloaded
        ///<summary>no implement function found</summary>
        kNoImpFunc,                     // no imp funct found
        ///<summary>operation not supported yet</summary>
        kNoImplementation,              // op not supported yet
        ///<summary>out of memory</summary>
        kOutOfMemory,                   // out of memory
        ///<summary>key not set</summary>
        kNullKey,                       // key not set
        ///<summary>object can't be edited</summary>
        kObjectNotEditable,             // obj can't be edited
        kNoKeySupported,
        ///<summary>geometry key create fail </summary>
        kGKeyNotSupported,              // geom key create fail
        kKeyCreationFailure,
        ///<summary>object is not geometry</summary>
        kNotGeom,                       // obj is not geometry
        ///<summary>silhouette geometry</summary>
        kSilhouette,                    // silhouette geom
        ///<summary>failure in type map</summary>
        kTypeMapFailure,                // failure in type map
        ///<summary>object not found </summary>
        kObjectNotFound,                // object not found
        kInvalidName,
        kNameAlreadyExists,

        kNoConstraints ,
        kNoChildren,


        ///<summary>user termination</summary>
        kUserTermination,               // user termination
        ///<summary>user-requested cancel</summary>
        kUserEscape,                    // user-requested cancel
        ///<summary>user selected a keyword</summary>
        kKeyWord,                        // user selected a keyword

        kNoClassRecord,
        kClassRecordAlreadyExists,
        kClassRecordInDb,
        kOutOfRange,                    // e.g. field index
        kReadError,                     // e.g. att read error

        kInvalidTypeForField,
        kInvalidTypeForSketchConstr,

        kObjectAlreadyExists,           // e.g. param object already exists
        kExprEvalFailure,
        kIllegalExpression,
        kCyclicDependency,

        kUnsupportedFeatType,
        kNoCombiner,
        kNoLocator,
        kNoTerminator,
            
        kUnmatchedLeafObject,
        kNoContainingComp,
        kUnmatchedActiveContext,

        kNoScene,

        kPartNotActive,
        kAmbiguousPartInfo,
        kNoPartInstance,
        ///<summary>attempted to create multiple base features on a part.</summary>
        kBaseFeatureAlreadyExists,      // attempted to create mutiple base features on a part.

        ///<summary>attempted update of read-only attribute</summary>
        kAttReadOnly,                   // attempted update of read-only attribute
        ///<summary>type mis-match on attributes</summary>
        kAttTypeMismatch,               // type mis-match on attributes
        ///<summary>NAV: Not A Value.</summary>
        kAttValueNAV,                   // NAV: "Not A Value"
        ///<summary>descriptor values inconsistent (wrt type)</summary>
        kIllegalDescriptor,             // descriptor values inconsistent (wrt type)
        ///<summary>multi-valued attribute in single-value context</summary>
        kAttMultiValued,                // multi-valued attribute in single-value context
        ///<summary>single-valued attribute in multi-value context </summary>
        kAttSingleValued,               // single-valued attribute in multi-value context
        ///<summary>cannot append to attribute value (not allowed)</summary>
        kAttNoAppend,                   // cannot append to attribute value (not allowed)

        ///<summary>illegal operation on base view (e.g. get parent)</summary>
        kBaseView,                      // illegal op on base view (e.g. get parent)
        ///<summary>sectioning operation requires context for cutline </summary>
        kNoCutlineContext,              // sectioning op requires context for cutline

        ///<summary>invalid/unsupported constraint type</summary>
        kInvalidConstrType,             // invalid/unsupported constraint type
        ///<summary>key to erased data passed</summary>
        kObjectErased,                  // key to erased data passed 
        ///<summary>argument geometry type not supported for constraint type.</summary>
        kBadItemType,                   // argument geomtry type not supported for constraint type
        ///<summary>geometric validation failed</summary>
        kGeomValidFailure,              // geometric validation failed
		///<summary>geometric validation failed</summary>
        kNoBaseOrdinate,                // no base ordinate defined on args 
        ///<summary>No sketch geometry passed in</summary>
        kNoConstrainableGeom,           // No sketch geometry passed in
        ///<summary>geometry from different sketches</summary>
        kNoCommonSketch,                // geometry from different sketches
        ///<summary>geometry from different parts</summary>
        kNoCommonPart,                  // geometry from different parts
		///<summary>keys point to same geometry</summary>
        kCoincidentGeom,                // keys point to same geometry
        ///<summary>keys reference same bodies</summary>
        kCoincidentBodies,              // keys reference same bodies
		///<summary>constraint would make sketch over constrained</summary>
        kModelOverConstrained,          // constraint would make sketch over constrained
        ///<summary>constrain inconsistent with existing constrains</summary>
        kModelInconsistent,             // constr inconsistent with existing constrs
        ///<summary>constrain already exists </summary>
        kConstraintExists,              // constr already exists

        ///<summary>invalid sketch type</summary>
        kInvalidSketchType,             // invalid sketch type
        ///<summary>Sketch type requires a start point,none found</summary>
        kMissingStartPoint,             // Sketch type requires a start point,none found
        ///<summary>no profile detected in geometry</summary>
        kNoSketchFound,                 // no profile detected in geometry
        ///<summary>Multiple of sketch type found</summary>
        kMultipleSketches,              // Multiple of sketch type found
        ///<summary>unable to add existing dimension</summary>
        kUnableToAddConstr,             // unable to add existing dimension
        ///<summary>geometry not planar to sketch plane</summary>
        kNonPlanarGeometry,             // geometry not planar to sketch plane

        ///<summary>named system variable not found</summary>
        kVariableNotFound,              // named system variable not found
        ///<summary>wrong type specified for variable</summary>
        kInvalidVariableType,           // wrong type specified for variable

        ///<summary>toolbody created instead of reg part/comp</summary>
        kToolBody,                      // toolbody created instead of reg part/comp
        ///<summary>leaf compdef might have toolbodies</summary>
        kLeafWithToolBodies,            // leaf compdef might have toolbodies
        ///<summary>grounded base part</summary>
        kGroundedBasePart,              // grounded base part
        ///<summary>both grounded base part and master def affected</summary>
        kGroundedBasePartIsMasterDef,   // both grounded base part and master def affected

        kObjectIsProxy,
        kInvalidDesignMode,
        kComputeFailure,
        kExternalDef,
        kExternalAttachment,
        kLockConflict,
        kSubAssemblyRequired,
        ///<summary>wants to delegate to conflicting imps</summary>
        kDelegationConflict,            // wants to delegate to conflicting imps
        ///<summary>wants to delegate to conflicting imps</summary>
        kNoBrep,                        // object instance has no associated Brep
        ///<summary>action available only in current database</summary>
        kNonCurrentDb,                  // action available only in current database
        ///<summary>Data not accessible from given database</summary>
        kNotAccessibleFromDb,           // Data not accessible from given database
        ///<summary>used for generic badness</summary>
        kUnspecified,                   // used for generic badness
        ///<summary>operation not defined in current Designer state</summary>
        kInvalidModelState,             // operation not defined in current Designer state
        ///<summary>model update did not complete (as opposed to to completing with compute errors)</summary>
        kUpdateFailure,                 // model update did not complete (as opposed to
		///<summary>object has no color override</summary>
        kNoColorOverride,               // object has no color override

        kNoNestedComposites,
        kCompositeNotStarted,
        kDuplicateCompositeEditCallback,
        kFeatureNotInComposite,

		///<summary>input must be a comp-in-def (use amiGetCompInDef()) </summary>
        kRequiresCompInDef,             // input must be a comp-in-def (use amiGetCompInDef())
        ///<summary>incompatible w.r.t. amiRefocusKey()</summary>
        kFocusMismatch,                 // incompatibile w.r.t. amiRefocusKey()
        ///<summary>not tangent continuous in edge path sketch</summary>
        kDiscontinuousGeom,             // not tangent continuous in edge path sketch
		///<summary>Failed to set structure entity edit mode.</summary>
        kSetStructModeEditEntityError,  // Failed to set structure entity edit mode.
        ///<summary>Not permitted on detail view</summary>
        kForbidDetailView,              // Not permitted on detail view
        ///<summary>Failed to resolve component view</summary>
        kFailResolveCompView,           // Failed to resolve component view
        ///<summary>Failed to resolve folder</summary>
        kFailResolveFolder,             // Failed to resolve folder
        ///<summary>Not permitted for annotation view with unresolved view definition</summary>
        kForbidUnresolvedDefAnnoView,   // Not permitted for annotation view with unresolved view definition
        ///<summary>Not permitted due to ghost</summary>
        kForbidGhost,                   // Not permitted due to ghost
        ///<summary>Not permitted on annotation sub view</summary>
        kForbidAnnoSubView,             // Not permitted on annotation sub view
        ///<summary>Cannot copy the single view of a component (Copy the component instead)</summary>
        kCopyCompSingleView,            // Cannot copy the single view of a component (Copy the component instead)
        ///<summary>Host database not active</summary>
        kHostDbNotActive,               // Host database not active
        ///<summary>Not permitted on standard components</summary>
        kForbidStandard,                // Not permitted on standard components
        ///<summary>Failed to lock component definition database</summary>
        kFailLockCompDefDb,             // Failed to lock component definition database
        ///<summary>Not permitted on feature</summary>
        kForbidFeature,                 // Not permitted on feature
        ///<summary>Failed to lock view definition database</summary>
        kFailLockViewDefDb,             // Failed to lock view definition database
        ///<summary>Entity cannot be edited</summary>
        kEntityNotEditable,             // Entity cannot be edited
        ///<summary>Failed to lock component database</summary>
        kFailLockCompDb,                // Failed to lock component database
        ///<summary>Not permitted on external feature</summary>
        kForbidExtFeature,              // Not permitted on external feature
        ///<summary>Not allowed for definition with 1 permitted instance only</summary>
        kForbidSingletonDef,            // Not allowed for definition with 1 permitted instance only
        ///<summary>Failed to lock view database</summary>
        kFailLockViewDb,                // Failed to lock view database
        ///<summary>Not permitted for SHAFT component Side or Section views</summary>
        kForbidShaftSideSectionView,    // Not permitted for SHAFT component Side or Section views
        ///<summary>Not permitted on detail subviews</summary>
        kForbidDetailSubView,           // Not permitted on detail subviews
        ///<summary>Not permitted because predefined reference is set</summary>
        kForbidPredefinedRefSet,        // Not permitted because predefined reference is set
        ///<summary>Failed to get next component definition name.</summary>
        kFailGetNextCompDefName,                  // Failed to get next component definition name.
        ///<summary>Failed to get next folder definition name.</summary>
        kFailGetNextFolderDefName,                // Failed to get next folder definition name.
        ///<summary>Failed to get next component view definition name (invalid argument).</summary>
        kFailGetNextCompViewDefNameInvalidArg,    // Failed to get next component view definition name (invalid argument).
        ///<summary>Failed to get next component view definition name.</summary>       
        kFailGetNextCompViewDefName,              // Failed to get next component view definition name.
        ///<summary>Failed to determine if component definition exists (invalid argument).</summary>
        kFailHasCompDefInvalidArg,                // Failed to determine if component definition exists (invalid argument).
        ///<summary>Failed to determine if component definition exists.</summary>
        kFailHasCompDef,                          // Failed to determine if component definition exists.
        ///<summary>Failed to determine if folder definition exists (invalid argument).</summary>
        kFailHasFolderDefInvalidArg,              // Failed to determine if folder definition exists (invalid argument).
        ///<summary>Failed to determine if folder definition exists.</summary>
        kFailHasFolderDef,                        // Failed to determine if folder definition exists.
        ///<summary>Failed to determine if component view definition exists (invalid argument).</summary>
        kFailHasCompViewDefInvalidArg,            // Failed to determine if component view definition exists (invalid argument).
        ///<summary>Failed to determine if component view definition exists.</summary>
        kFailHasCompViewDef,                      // Failed to determine if component view definition exists.
        ///<summary>Failed to determine if entity is in active target (invalid argument).</summary>
        kFailIsInActTgtInvalidArg,                // Failed to determine if entity is in active target (invalid argument).
        ///<summary>Failed to determine if entity is in active target.</summary>
        kFailIsInActTgt,                          // Failed to determine if entity is in active target.
        ///<summary>Failed to determine if entity is free entity (invalid argument</summary>
        kFailIsFreeEntityInvalidArg,              // Failed to determine if entity is free entity (invalid argument).
        ///<summary>Failed to determine if entity is free entity.</summary>
        kFailIsFreeEntity,                        // Failed to determine if entity is free entity.
        ///<summary>Failed to determine if entity is allowed in 2D structure (invalid argument).</summary>
        kFailIsEntityAllowedInvalidArg,           // Failed to determine if entity is allowed in 2D structure (invalid argument).
        ///<summary>Failed to determine if 2D structure is enabled.</summary>
        kFailIsStructEnabled,                     // Failed to determine if 2D structure is enabled.
        ///<summary>Failed to determine if component view is ghost view.</summary>
        kFailViewIsGhost,                         // Failed to determine if component view is ghost view.
        ///<summary>Failed to determine if component has ghost views (invalid argument).</summary>
        kFailHasGhostViewsInvalidArg,             // Failed to determine if component has ghost views (invalid argument).
        ///<summary>Failed to determine if component has ghost views.</summary>
        kFailHasGhostViews,                       // Failed to determine if component has ghost views.
        ///<summary>Failed to determine if component is reference (invalid argument).</summary>
        kFailGetReferenceInvalidArg,              // Failed to determine if component is reference (invalid argument).
        ///<summary>Failed to determine if component is reference.</summary>
        kFailGetReference,                        // Failed to determine if component is reference.
        ///<summary>Failed to set component as reference (invalid argument).</summary>
        kFailSetReferenceInvalidArg,              // Failed to set component as reference (invalid argument).
        ///<summary>Failed to set component as reference.</summary>
        kFailSetReference,                        // Failed to set component as reference.
        ///<summary>Failed to update 2D structure with entity changes in model space.</summary>
        kFailUpdateEntities,                      // Failed to update 2D structure with entity changes in model space.
        ///<summary>Operation not permitted on annotation view.</summary>
        kForbidAnnoView,                          // Operation not permitted on annotation view.
        ///<summary>Operation not permitted on standard part.</summary>
        kForbidStandardPart,                      // Operation not permitted on standard part.
        ///<summary>Invalid parent view selected.</summary>
        kInvalidParentView,                       // Invalid parent view selected.
    };

    ///<summary>Enumeration of Phantom State of Component Definition.</summary>
    enum PhantomState
    {
      kNormalDef = 0,
      kPhantomDef = 1,
      kPhantomDefInCurrent = 2
    };
};


namespace Ami
{
    enum FlatStatus
    {
        eOk                             = 0,
        eMakeMeProxy                    = 301,
        eInternalUnsupported            = 1001,
        ///<summary>used for generic badness</summary>
        eBad                            = kUnspecified,
        eInvalidArg                     = kInvalidArg,
        ///<summary>required database is unloaded</summary>
        eDatabaseUnloaded               = kDatabaseUnloaded,
        ///<summary>no implement function found</summary>
        eNoImpFunc                      = kNoImpFunc,
        ///<summary>operation not supported yet</summary>
        eNoImplementation               = kNoImplementation,
        ///<summary>out of memory</summary>
        eOutOfMemory                    = kOutOfMemory,
        ///<summary>key not set </summary>
        eNullKey                        = kNullKey,
        ///<summary>obj can't be edited</summary>
        eObjectNotEditable              = kObjectNotEditable,
        eNoKeySupported                 = kNoKeySupported,
        ///<summary>geometry key create fail</summary>
        eGKeyNotSupported               = kGKeyNotSupported,
        eKeyCreationFailure             = kKeyCreationFailure,
        ///<summary>object is not geometry</summary>
        eNotGeom                        = kNotGeom,
        ///<summary>failure in type map</summary>
        eTypeMapFailure                 = kTypeMapFailure,
        eNotApplicable                  = kNotApplicable,

        eNoConstraints                  = kNoConstraints,
        eNoChildren                     = kNoChildren,
        ///<summary>External Component not found</summary>
        eExternalComponentNotFound      = kObjectNotFound,

        eInvalidName                    = kInvalidName,
        eNameAlreadyExists              = kNameAlreadyExists,
		///<summary>user termination</summary>
        eUserTermination                = kUserTermination,
        ///<summary>user-requested cancel</summary>
        eUserEscape                     = kUserEscape,

        eNoClassRecord                  = kNoClassRecord,
        eClassRecordAlreadyExists       = kClassRecordAlreadyExists,
        eClassRecordInDb                = kClassRecordInDb,
        ///<summary>Field index out of range</summary>
        eFieldIndexOutOfRange           = kOutOfRange,
        eInvalidFieldName               = kInvalidName,
        eInvalidFieldType               = kInvalidTypeForField,
        ///<summary>Attribute Read error</summary>
        eAttributeReadError             = kReadError,

        eInvalidSketchConstrType        = kInvalidTypeForSketchConstr,
		///<summary>param object already exists</summary>
        eParamAlreadyExists             = kObjectAlreadyExists,
        eExprEvalFailure                = kExprEvalFailure,
        eIllegalExpression              = kIllegalExpression,
        ///<summary>Parameter not found</summary>
        eParamNotFound                  = kObjectNotFound,
        eCyclicDependency               = kCyclicDependency,

        eUnsupportedFeatType            = kUnsupportedFeatType,
        eNoCombiner                     = kNoCombiner,
        eNoLocator                      = kNoLocator,
        eNoTerminator                   = kNoTerminator,
            
        eUnmatchedLeafObject            = kUnmatchedLeafObject,
        eNoContainingComp               = kNoContainingComp,
        eUnmatchedActiveContext         = kUnmatchedActiveContext,

        eNoScene                        = kNoScene,

        ePartNotActive                  = kPartNotActive,
        eAmbiguousPartInfo              = kAmbiguousPartInfo,
        eNoPartInstance                 = kNoPartInstance,
        ///<summary>attempted to create mutiple base features on a part</summary>
        eBaseFeatureAlreadyExists       = kBaseFeatureAlreadyExists,
		///<summary>attempted update of read-only attribute</summary>
        eAttReadOnly                    = kAttReadOnly,
        ///<summary>type mis-match on attributes</summary>
        eAttTypeMismatch                = kAttTypeMismatch,
        ///<summary>NAV: Not A Value.</summary>
        eAttValueNAV                    = kAttValueNAV,
        ///<summary>descriptor values inconsistent (wrt type)</summary>
        eIllegalDescriptor              = kIllegalDescriptor,
        ///<summary>multi-valued attribute in single-value context</summary>
        eAttMultiValued                 = kAttMultiValued,
        ///<summary>single-valued attribute in multi-value context</summary>
        eAttSingleValued                = kAttSingleValued,
        ///<summary>cannot append to attribute value (not allowed)</summary>
        eAttNoAppend                    = kAttNoAppend,
		///<summary>illegal operation on base view (e.g. get parent)</summary>
        eBaseView                       = kBaseView,
        ///<summary>sectioning operation requires context for cutline</summary>
        eNoCutlineContext               = kNoCutlineContext,
		///<summary>invalid/unsupported constraint type</summary>
        eInvalidConstrType              = kInvalidConstrType,
        ///<summary>key to erased data passed</summary>
        eArgErased                      = kObjectErased,
        ///<summary>argument geometry type not supported for constraint type</summary>
        eBadItemType                    = kBadItemType,
        ///<summary>geometric validation failed</summary>
        eGeomValidFailure               = kGeomValidFailure,
		///<summary>no base ordinate defined on args</summary>
        eNoBaseOrdinate                 = kNoBaseOrdinate,
        ///<summary>No sketch geometry passed in</summary>
        eNoConstrainableGeom            = kNoConstrainableGeom,
        ///<summary>geometry from different sketches</summary>
        eNoCommonSketch                 = kNoCommonSketch,
        ///<summary>geometry from different parts</summary>
        eNoCommonPart                   = kNoCommonPart,
        ///<summary>keys point to same geometry</summary>
        eCoincidentGeom                 = kCoincidentGeom,
		///<summary>constraint would make sketch over constrained</summary>
        eModelOverConstrained           = kModelOverConstrained,
        ///<summary>constrain inconsistent with existing constrains</summary>
        eModelInconsistent              = kModelInconsistent,
        ///<summary>constrain already exists</summary>
        eConstraintExists               = kConstraintExists,

        eInternalFailure                = kInternalFailure,
		///<summary>Invalid sketch type</summary>
        eInvalidSketchType              = kInvalidSketchType,
        ///<summary>Sketch type requires a start point,none found</summary>
        eMissingStartPoint              = kMissingStartPoint,
        ///<summary>no profile detected in geometry</summary>
        eNoSketchFound                  = kNoSketchFound,
        ///<summary>Multiple of sketch type found</summary>
        eMultipleSketches               = kMultipleSketches,
        ///<summary>unable to add existing dimension</summary>
        eUnableToAddConstr              = kUnableToAddConstr,
        ///<summary>geometry not planar to sketch plane</summary>
        eNonPlanarGeometry              = kNonPlanarGeometry,

        ///<summary>named system variable not found</summary>
        eVariableNotFound               = kVariableNotFound,
        ///<summary>wrong type specified for variable</summary>
        eInvalidVariableType            = kInvalidVariableType,

        eObjectIsProxy                  = kObjectIsProxy,
        eInvalidDesignMode              = kInvalidDesignMode,
        eComputeFailure                 = kComputeFailure,
        eExternalDef                    = kExternalDef,
        eSubAssemblyRequired            = kSubAssemblyRequired,
        ///<summary>wants to delegate to conflicting imps</summary>
        eDelegationConflict             = kDelegationConflict,
        ///<summary>object has no color override</summary>
        eNoColorOverride                = kNoColorOverride,

        eNoNestedComposites             = kNoNestedComposites,
        eCompositeNotStarted            = kCompositeNotStarted,
        eDuplicateCompositeEditCallback = kDuplicateCompositeEditCallback,
        eFeatureNotInComposite          = kFeatureNotInComposite,
        ///<summary>Failed to set structure entity edit mode</summary>
        eSetStructModeEditEntityError   = kSetStructModeEditEntityError,
        ///<summary>Not permitted on detail view</summary>
        eForbidDetailView               = kForbidDetailView,     
        ///<summary>Failed to resolve component view</summary>
        eFailResolveCompView            = kFailResolveCompView,  
        ///<summary>Failed to resolve folder</summary>
        eFailResolveFolder              = kFailResolveFolder,    
        ///<summary>Not permitted for annotation view with unresolved view definition</summary>
        eForbidUnresolvedDefAnnoView    = kForbidUnresolvedDefAnnoView,  
        ///<summary>Not permitted due to ghost</summary>
        eForbidGhost                    = kForbidGhost,  
        ///<summary>Not permitted on annotation sub view</summary>
        eForbidAnnoSubView              = kForbidAnnoSubView,
        ///<summary>Cannot copy the single view of a component (Copy the component instead)</summary>
        eCopyCompSingleView             = kCopyCompSingleView,
        ///<summary>Host database not active</summary>
        eHostDbNotActive                = kHostDbNotActive,  
        ///<summary>Not permitted on standard components</summary>
        eForbidStandard                 = kForbidStandard,     
        ///<summary>Failed to lock component definition database</summary>
        eFailLockCompDefDb              = kFailLockCompDefDb,   
        ///<summary>Not permitted on feature</summary>
        eForbidFeature                  = kForbidFeature,    
        ///<summary>Failed to lock view definition database</summary>
        eFailLockViewDefDb              = kFailLockViewDefDb,  
        ///<summary>Entity cannot be edited</summary>
        eEntityNotEditable              = kEntityNotEditable,  
        ///<summary>Failed to lock component database</summary>
        eFailLockCompDb                 = kFailLockCompDb,  
        ///<summary>Not permitted on external feature</summary>
        eForbidExtFeature               = kForbidExtFeature,   
        ///<summary>Not allowed for definition with 1 permitted instance only</summary>
        eForbidSingletonDef             = kForbidSingletonDef,
        ///<summary>Failed to lock view database</summary>
        eFailLockViewDb                 = kFailLockViewDb,
        ///<summary>Not permitted for SHAFT component Side or Section views</summary>
        eForbidShaftSideSectionView     = kForbidShaftSideSectionView,
        ///<summary>Not permitted on detail subviews</summary>
        eForbidDetailSubView            = kForbidDetailSubView,
        ///<summary>Not permitted because predefined reference is set</summary>
        eForbidPredefinedRefSet         = kForbidPredefinedRefSet,
        ///<summary>Failed to get next component definition name</summary>
        eFailGetNextCompDefName                   = kFailGetNextCompDefName,
        ///<summary>Failed to get next folder definition name.</summary>
        eFailGetNextFolderDefName                 = kFailGetNextFolderDefName,
        ///<summary>Failed to get next component view definition name (invalid argument).</summary>
        eFailGetNextCompViewDefNameInvalidArg     = kFailGetNextCompViewDefNameInvalidArg,
        ///<summary>Failed to get next component view definition name</summary>
        eFailGetNextCompViewDefName               = kFailGetNextCompViewDefName,
        ///<summary>Failed to determine if component definition exists (invalid argument).</summary>
        eFailHasCompDefInvalidArg                 = kFailHasCompDefInvalidArg,
        ///<summary>Failed to determine if component definition exists</summary>
        eFailHasCompDef                           = kFailHasCompDef,
        ///<summary>Failed to determine if folder definition exists (invalid argument).</summary>
        eFailHasFolderDefInvalidArg               = kFailHasFolderDefInvalidArg,
        ///<summary>Failed to determine if folder definition exists</summary>
        eFailHasFolderDef                         = kFailHasFolderDef,
        ///<summary>Failed to determine if component view definition exists (invalid argument).</summary>
        eFailHasCompViewDefInvalidArg             = kFailHasCompViewDefInvalidArg,
        ///<summary>Failed to determine if component view definition exists</summary>
        eFailHasCompViewDef                       = kFailHasCompViewDef,
        ///<summary>Failed to determine if entity is in active target (invalid argument).</summary>
        eFailIsInActTgtInvalidArg                 = kFailIsInActTgtInvalidArg,
        ///<summary>Failed to determine if entity is in active target</summary>
        eFailIsInActTgt                           = kFailIsInActTgt,
        ///<summary>Failed to determine if entity is free entity (invalid argument).</summary>
        eFailIsFreeEntityInvalidArg               = kFailIsFreeEntityInvalidArg,
        ///<summary>Failed to determine if entity is free entity</summary>
        eFailIsFreeEntity                         = kFailIsFreeEntity,
        ///<summary>Failed to determine if entity is allowed in 2D structure (invalid argument).</summary>
        eFailIsEntityAllowedInvalidArg            = kFailIsEntityAllowedInvalidArg,
        ///<summary>Failed to determine if 2D structure is enabled.</summary>
        eFailIsStructEnabled                      = kFailIsStructEnabled,
        ///<summary>Failed to determine if component view is ghost view.</summary>
        eFailViewIsGhost                          = kFailViewIsGhost,
        ///<summary>Failed to determine if component has ghost views (invalid argument).</summary>
        eFailHasGhostViewsInvalidArg              = kFailHasGhostViewsInvalidArg,
        ///<summary>Failed to determine if component has ghost views</summary>
        eFailHasGhostViews                        = kFailHasGhostViews,
        ///<summary>Failed to determine if component is reference (invalid argument).</summary>
        eFailGetReferenceInvalidArg               = kFailGetReferenceInvalidArg,
        ///<summary>Failed to determine if component is reference</summary>
        eFailGetReference                         = kFailGetReference,
        ///<summary>Failed to determine if component is reference.</summary>
        eFailSetReferenceInvalidArg               = kFailSetReferenceInvalidArg,
        ///<summary>Failed to set component as reference</summary>
        eFailSetReference                         = kFailSetReference,
        ///<summary>Failed to update 2D structure with entity changes in model space.</summary>
        eFailUpdateEntities                       = kFailUpdateEntities,
        ///<summary>Operation not permitted on annotation view.</summary>
        eForbidAnnoView                           = kForbidAnnoView,
        ///<summary>Operation not permitted on standard part</summary>
        eForbidStandardPart                       = kForbidStandardPart,
        ///<summary>Invalid parent view selected.</summary>
        eInvalidParentView                        = kInvalidParentView
    };

    typedef AmiStatus    Status;
};
typedef Ami::FlatStatus            AmiFlatStatus;


///<summary>All MCADAPI functions return AmiStatus objects. The AmiStatus holds a simple status to convey the outcome of the function. 
///This includes error codes, warning codes, and success codes.</summary>
class AMIAPI AmiStatus
{
public:
    AmiStatus();
    AmiStatus(Ami::StatusCode);
    AmiStatus(Ami::StatusCode, Ami::Severity);
    AmiStatus(Ami::StatusCode, Ami::Severity, int argIndex);
    AmiStatus(Ami::StatusCode, Ami::Severity, int argIndex, int attrKeyword);
    AmiStatus(Ami::FlatStatus);
    AmiStatus(Acad::ErrorStatus);
    AmiStatus(AmdtAttr::Status);
    AmiStatus(const AmiStatus&);
    AmiStatus(int);
	///<summary>Return true if this is not an error status.</summary>
    bool            success()       const;
    ///<summary>Returns true if this is an error status.</summary>
    bool            failure()       const;
	///<summary>Returns the severity of the status.</summary>
    Ami::Severity   severity()      const;
    ///<summary>Returns an enum value which represents the basic type of status.</summary>
    Ami::StatusCode symbol()        const;
    ///<summary>Returns the position of the function argument that gave rise to the status. 
	///Numbering begins with 0, and a negative number is returned if no argument has been singled-out as the cause.</summary>
    int             argIndex()      const;
    ///<summary>When argIndex() indicates that an array input argument is the cause of the status, 
	///and the problem can be further pinpointed to a particular element, 
	///then this function returns the index of that element. 
	///Numbering begins at 0, and a negative number is returned if no element is singled-out.</summary>
    int             arrayIndex()    const;
    ///<summary>When argIndex() indicates that a descriptor input argument is the cause of the status, 
	///and the problem can be further isolated to a single attribute, then this function returns the keyword for that attribute. 
	///Note: the keyword is passed back as an 'int' and not as an enum. 
	///This is because there is no single enum datatype for attributes of all descriptor types (the enum values are distinct, 
	///however, so there is no loss of information in using an 'int' here).</summary>
    int             attrKeyword()   const;
    ///<summary>Returns a string holding a short text description of the status.</summary>
    TSTDSTRING     text()          const;

    bool operator==(const Ami::FlatStatus&)   const;
    bool operator!=(const Ami::FlatStatus&)   const;
    bool operator==(const AmiStatus&)         const;
    bool operator!=(const AmiStatus&)         const;
    bool operator==(const Acad::ErrorStatus&) const;
    bool operator!=(const Acad::ErrorStatus&) const;
    bool operator==(const AmdtAttr::Status&)      const;
    bool operator!=(const AmdtAttr::Status&)      const;
    bool operator==(const int&)               const;
    bool operator!=(const int&)               const;

    bool       operator< (const AmiStatus&)   const;
    AmiStatus& operator+=(const AmiStatus&);


    operator Ami::FlatStatus   ()   const;
    operator Acad::ErrorStatus ()   const;
    operator int               ()   const;
    operator AmdtAttr::Status  ()   const;

public:
    ///<summary>Sets the severity to the given level.</summary>
    AmiStatus&      setSeverity(Ami::Severity);
    ///<summary>Sets the symbol to the given StatusCode value.</summary>
    AmiStatus&      setSymbol(Ami::StatusCode);
    ///<summary>Sets the arg-index to the given value.</summary>
    AmiStatus&      setArgIndex(int);
    ///<summary>Sets the array-index to the given value. 
	///This will overwrite the attribute-keyword if it is set. 
	///The attribute-keyword and array-index cannot be used together in the same AmiStatus instance.</summary>
    AmiStatus&      setArrayIndex(int);
    ///<summary>Sets the attribute-keyword to the given value. 
	///This will overwrite the array-index if it is set. 
	///The attribute-keyword and array-index cannot be used together in the same AmiStatus instance.</summary>
    AmiStatus&      setAttrKeyword(int);

private:
    Adesk::UInt32       mData;      // 32-bit encodement
};


bool AMIAPI operator==(const Ami::FlatStatus&, const AmiStatus&);
bool AMIAPI operator!=(const Ami::FlatStatus&, const AmiStatus&);



#define AMI_SEVERITY_BITS      0xC0000000       /*  2 bits */
#define AMI_SYMBOL_BITS        0x3FFE0000       /* 13 bits */

#define AMI_SEVERITY_SHIFT     30           /* 32-2           =30 */
#define AMI_SYMBOL_SHIFT       17           /* 32-2-13        =17 */


#define AMI_STATUS_ENCODEMENT(sev,sym)               \
                                                     \
        (((Adesk::UInt32)(sev) << AMI_SEVERITY_SHIFT)\
         |                                           \
         ((Adesk::UInt32)(sym) << AMI_SYMBOL_SHIFT))

#define AMI_SET_SEVERITY(bits, sev) \
        bits = (bits & ~AMI_SEVERITY_BITS) \
               | ((Adesk::UInt32)(sev) << AMI_SEVERITY_SHIFT)

#define AMI_SET_SYMBOL(bits, sym) \
        bits = (bits & ~AMI_SYMBOL_BITS) \
               | ((Adesk::UInt32)(sym) << AMI_SYMBOL_SHIFT)



inline AmiStatus::AmiStatus()
    : mData(0x0)                // kInfo,kOk
{
}
inline AmiStatus::AmiStatus(Ami::StatusCode sym, Ami::Severity sev)
    : mData(AMI_STATUS_ENCODEMENT(sev,sym))
{
}
inline AmiStatus::AmiStatus(Ami::StatusCode sym, Ami::Severity sev,
                            int argIndex)
    : mData(AMI_STATUS_ENCODEMENT(sev,sym))
{
    setArgIndex(argIndex);
}
inline AmiStatus::AmiStatus(Ami::StatusCode sym, Ami::Severity sev,
                            int argIndex, int attrKeyword)
    : mData(AMI_STATUS_ENCODEMENT(sev,sym))
{
    setArgIndex(argIndex);
    setAttrKeyword(attrKeyword);
}
inline AmiStatus::AmiStatus(const AmiStatus& x)
    : mData(x.mData)
{
}
inline AmiStatus::AmiStatus(Ami::FlatStatus oldSymbol)
    : mData(0x0)
{
    if (oldSymbol != Ami::eOk)
        mData = AMI_STATUS_ENCODEMENT(Ami::kError, oldSymbol);
}


__forceinline AmiStatus::operator Ami::FlatStatus ()  const
{
    return failure() ? (Ami::FlatStatus) symbol() : Ami::eOk;
}


inline bool AmiStatus::success()    const
{
    return (Adesk::Int32)mData >= 0;
}
inline bool AmiStatus::failure()    const
{
    return (Adesk::Int32)mData < 0;
}

inline AmiStatus& AmiStatus::setSeverity(Ami::Severity sev)
{
    AMI_SET_SEVERITY(mData, sev);
    return *this;
}
inline AmiStatus& AmiStatus::setSymbol(Ami::StatusCode c)
{
    AMI_SET_SYMBOL(mData, c);
    return *this;
}

inline bool AmiStatus::operator==(const AmiStatus& rhs)  const
{
    return  mData == rhs.mData;
}
inline bool AmiStatus::operator!=(const AmiStatus& rhs)  const
{
    return  mData != rhs.mData;
}

inline Ami::Severity  AmiStatus::severity()  const
{
    return (Ami::Severity)  ((mData & AMI_SEVERITY_BITS) >> AMI_SEVERITY_SHIFT);
}

inline Ami::StatusCode AmiStatus::symbol()  const
{
    return  (Ami::StatusCode)  ((mData & AMI_SYMBOL_BITS) >> AMI_SYMBOL_SHIFT);
}

inline bool AmiStatus::operator< (const AmiStatus& rhs)  const
{
    if (severity() < rhs.severity())
        return true;
    else if (severity()==Ami::kInfo
             && symbol()==Ami::kOk
             && rhs.symbol()!=Ami::kOk)
        return true;
    return false;
}

inline AmiStatus& AmiStatus::operator+=(const AmiStatus& rhs)
{
    if (*this < rhs)
    {
        setSeverity(rhs.severity());
        setSymbol(rhs.symbol());
    }
    return *this;
}


inline bool AmiStatus::operator==(const Ami::FlatStatus& rhs)  const
{
    return ((Ami::FlatStatus) *this) == rhs;
}
inline bool AmiStatus::operator!=(const Ami::FlatStatus& rhs)  const
{
    return ((Ami::FlatStatus) *this) != rhs;
}

inline bool operator==(const Ami::FlatStatus& lhs, const AmiStatus& rhs)
{
    return lhs == (Ami::FlatStatus)rhs;
}
inline bool operator!=(const Ami::FlatStatus& lhs, const AmiStatus& rhs)
{
    return lhs != (Ami::FlatStatus)rhs;
}


#endif  // AMISTATUS_H
