Adobe.com
Contents Suites Classes Class Index Member Index

IAICopyScope.h

Go to the documentation of this file.
00001 #ifndef _IAICOPYSCOPE_H_
00002 #define _IAICOPYSCOPE_H_
00003 
00004 /*
00005  *        Name: IAICopyScope.h
00006  *   $Revision: 1 $
00007  *      Author:
00008  *        Date:
00009  *     Purpose: Wrapper class for AIArt copy scope objects.
00010  *
00011  * ADOBE SYSTEMS INCORPORATED
00012  * Copyright 2003-2007 Adobe Systems Incorporated.
00013  * All rights reserved.
00014  *
00015  * NOTICE:  Adobe permits you to use, modify, and distribute this file
00016  * in accordance with the terms of the Adobe license agreement
00017  * accompanying it. If you have received this file from a source other
00018  * than Adobe, then your use, modification, or distribution of it
00019  * requires the prior written permission of Adobe.
00020  *
00021  */
00022 
00023 #include "AIArt.h"
00024 #include <exception>
00025 
00026 namespace ai {
00027 
00030 #define kAICopyScopeAlreadyInitialized  'CSAI'
00031 
00045 class CopyScope {
00046 
00047 public:
00051         CopyScope() AINOTHROW
00052         : fScope(0)
00053         {}
00054 
00059         explicit CopyScope(AICopyScopeKind kind)
00060         : fScope(0)
00061         {
00062                 Initialize(kind);
00063         }
00064 
00069         ~CopyScope()
00070         {
00071                 if (IsValid())
00072                 {
00073                         (void) Terminate(std::nothrow);
00074                 }
00075         }
00076 
00080         bool IsValid() const AINOTHROW
00081         {
00082                 return fScope != 0;
00083         }
00084 
00090         AIErr Initialize(AICopyScopeKind kind, const std::nothrow_t&) AINOTHROW
00091         {
00092                 AIErr result = kNoErr;
00093 
00094                 if (!IsValid())
00095                 {
00096                         result = sAIArt->CreateCopyScope(kind, &fScope);
00097                 }
00098                 else
00099                 {
00100                         result = kAICopyScopeAlreadyInitialized;
00101                 }
00102 
00103                 return result;
00104         }
00105 
00110         void Initialize(AICopyScopeKind kind)
00111         {
00112                 AIErr result = Initialize(kind, std::nothrow);
00113                 if ( result )
00114                         throw ai::Error(result);
00115         }
00116 
00122         AIErr Terminate(const std::nothrow_t&) AINOTHROW
00123         {
00124                 AIErr result = kNoErr;
00125 
00126                 if (IsValid())
00127                 {
00128                         result = sAIArt->DestroyCopyScope(fScope);
00129                         fScope = 0;
00130                 }
00131 
00132                 return result;
00133         }
00134 
00140         void Terminate()
00141         {
00142                 AIErr result = Terminate(std::nothrow);
00143                 if ( result )
00144                         throw ai::Error(result);
00145         }
00146 
00147 private:
00149         CopyScope(const CopyScope& scope);
00151         CopyScope& operator= (const CopyScope& scope);
00152 
00153 private:
00154         AICopyScopeHandle fScope;
00155 };
00156 
00157 
00158 } // end of namespace ai
00159 
00160 
00161 #endif  // _IAICOPYSCOPE_H_


Contents Suites Classes Class Index Member Index
Adobe Solutions Network
 
Copyright © 2016 Adobe Systems Incorporated. All rights reserved.
Terms of Use Online Privacy Policy Adobe and accessibility Avoid software piracy Permissions and Trademarks