Adobe.com
Contents Suites Classes Class Index Member Index

ai::ArtMatcher Class Reference

A stack based wrapper class for inquiring about the selection and matched art over AIMatchingArtSuite. More...

#include <IAIArtMatcher.hpp>

List of all members.

Public Types

enum  eArtMatcherErrors {
  AM_OK = kNoErr, AM_InvalidIndex, AM_InvalidSuite, AM_UnknownException,
  AM_NumErrs, AM_NoResult
}
 

Errors returned by ai::ArtMatcher.

More...

Public Member Functions

 ArtMatcher (size_t iNumSpecs=0, AIBoolean matchArtInDictionaries=false)
 Default constructor.
 ArtMatcher (const AIMatchingArtSpec &spec, AIBoolean matchArtInDictionaries=false)
 Constructor with one spec.
 ArtMatcher (const ArtMatcher &)
 Copy is not allowed.
ArtMatcheroperator= (const ArtMatcher &)
 Assignment is not allowed.
 ArtMatcher (ArtMatcher &&other) AINOEXCEPT
 Move Constructor.
ArtMatcheroperator= (ArtMatcher &&other) AINOEXCEPT
 Move Assignment.
AIErr SetSpec (size_t iX, ai::int16 shType, ai::int32 lWhichAttr, ai::int32 lAttr)
 Set spec if size is already allocated.
AIErr PushSpec (ai::int16 shType, ai::int32 lWhichAttr, ai::int32 lAttr)
 Add spec to the end.
AIErr GetMatchingArt ()
 AIMatchingArtSuite::GetMatchingArt()
AIErr GetSelectedArt ()
 AIMatchingArtSuite::GetSelectedArt()
AIErr GetMatchingArtFromLayerList (AILayerList layerList)
 AIMatchingArtSuite::GetMatchingArtFromLayerList()
AIErr GetMatchingArtFromArt (AIArtHandle art)
 AIMatchingArtSuite::GetMatchingArtFromArt()
AIErr GetArtForCurrentPathStyle ()
 AIMatchingArtSuite::GetArtForCurrentPathStyle()
AIErr GetSelectedArtFromLayerList (AILayerList layerList)
 AIMatchingArtSuite::GetSelectedArtFromLayerList()
ai::int32 GetNumMatches () const
 Returns the number of art objects matched by last GetMatchingArt() or GetSelectedArt() call.
AIArtHandle GetMatchedArt (size_t iX) const
 Returns nth AIArtHandle if the last GetMatchingArt() or GetSelectedArt() call succeeded.
AIArtHandle operator[] (size_t iX) const
ai::ArtSet GetArtSet () const
 Returns a stack based AIArtSet Object which can be used in APIs which needs an AIArtSet.
AIErr GetLastError () const AINOEXCEPT
 Get AIErr for the last query, though it is usually not required.
void ClearMatchedArt (size_t iX)
 operator bool () const AINOEXCEPT
 Check if the last query has some interesting data.
iterator begin () const AINOEXCEPT
 iterators for range based for loops
iterator end () const AINOEXCEPT
 iterators for range based for loops
reverse_iterator rbegin () const AINOEXCEPT
reverse_iterator rend () const AINOEXCEPT
void clear () AINOEXCEPT
 Clear the stored handles only, the spec is intact and will be used in next query.
AIArtHandle ** release () AINOEXCEPT
 Transfer the ownership of stored art handles, call it only if you know what you are doing.

Detailed Description

A stack based wrapper class for inquiring about the selection and matched art over AIMatchingArtSuite.

Always prefer this class over directly calling APIs in AIMatchingArtSuite.

Enhanced to support C++11 semantics. For example, range-based loops, move constructor and assignment, and added support for dynamic spec specification as well as automatic size computation.

Example 1.1: Statically allocate spec, let ArtMatcher figure out the size, recommended approach AIMatchingArtSpec spec[] = { { kRasterArt, kArtSelected, kArtSelected}, { kPlacedArt, kArtSelected, kArtSelected} };

ArtMatcher matcher(spec); matcher.GetMatchingArt();

for(auto art: matcher) // This loop is safe even if the earlier call didn't return any art, the loop won't enter { work with art }

WARNING NOTE!!! Don't create a spec array with single braces even for one element e.g, never do this, AIMatchingArtSpec now has a default constructor and it creates an array with size 3 AIMatchingArtSpec spec[] = { kRasterArt, kArtSelected, kArtSelected};

Example 1.2 Special constructor for one spec ArtMatcher matcher(AIMatchingArtSpec{ kAnyArt, kArtFullySelected, kArtFullySelected }); matcher.GetMatchingArt();

for(auto art: matcher) // This loop is safe even if the earlier call didn't return any art, the loop won't enter { work with art }

Example 2: Push specs at runtime, without worrying about upfront allocation ArtMatcher matcher; matcher.PushSpec(kRasterArt, kArtSelected, kArtSelected); matcher.PushSpec(kPlacedArt, kArtSelected, kArtSelected);

AIErr err = matcher.GetMatchingArt(); if(!err) { auto count = matcher.GetNumMatches(); for(decltype(count) i = 0; i < count; ++i) { auto art = matcher.GetMatchedArt(i); } }

Example 3: Reserve space and set index based specs. The old way is still supported. It will work even if you don't reserve space upfront ArtMatcher matcher(1); matcher.SetSpec(0, kArtSelected, kArtSelected); AIErr err = matcher.GetMatchingArt(); ... use range based or direct access loop

Example 4: Bool operator ArtMatcher matcher(spec); matcher.GetMatchingArt(); if(matcher) // Has at least one element; this check is not required for range-based loops { auto firstObject = *(matcher.begin()); }

Example 5: Reverse iterator (last to first) ArtMatcher matcher(spec); matcher.GetMatchingArt(); for (auto iter = matcher.rbegin(); iter != matcher.rend(); ++iter) { auto art = *iter; }

Example 6: Fetch all selected objects ArtMatcher matcher; matcher.GetSelectedArt();

for(auto art: matcher) // This loop is safe even if the earlier call didn't return any art, the loop won't enter { process selected objects }


Member Enumeration Documentation

Errors returned by ai::ArtMatcher.

Enumerator:
AM_OK 
AM_InvalidIndex 
AM_InvalidSuite 
AM_UnknownException 
AM_NumErrs 
AM_NoResult 

Constructor & Destructor Documentation

ai::ArtMatcher::ArtMatcher ( size_t  iNumSpecs = 0,
AIBoolean  matchArtInDictionaries = false 
) [inline, explicit]

Default constructor.

ai::ArtMatcher::ArtMatcher ( const AIMatchingArtSpec spec,
AIBoolean  matchArtInDictionaries = false 
) [inline]

Constructor with one spec.

ai::ArtMatcher::ArtMatcher ( const ArtMatcher  ) 

Copy is not allowed.

ai::ArtMatcher::ArtMatcher ( ArtMatcher &&  other  ) 

Move Constructor.


Member Function Documentation

iterator ai::ArtMatcher::begin (  )  const [inline]

iterators for range based for loops

Referenced by rend().

void ai::ArtMatcher::clear (  ) 

Clear the stored handles only, the spec is intact and will be used in next query.

References AIMdMemorySuite::MdMemoryDisposeHandle.

void ai::ArtMatcher::ClearMatchedArt ( size_t  iX  ) 
iterator ai::ArtMatcher::end (  )  const [inline]

iterators for range based for loops

Referenced by rbegin().

AIErr ai::ArtMatcher::GetArtForCurrentPathStyle (  ) 
ai::ArtSet ai::ArtMatcher::GetArtSet (  )  const

Returns a stack based AIArtSet Object which can be used in APIs which needs an AIArtSet.

AIErr ai::ArtMatcher::GetLastError (  )  const [inline]

Get AIErr for the last query, though it is usually not required.

AIArtHandle ai::ArtMatcher::GetMatchedArt ( size_t  iX  )  const

Returns nth AIArtHandle if the last GetMatchingArt() or GetSelectedArt() call succeeded.

Referenced by operator[]().

AIErr ai::ArtMatcher::GetMatchingArt ( void   ) 
AIErr ai::ArtMatcher::GetMatchingArtFromArt ( AIArtHandle  art  ) 
AIErr ai::ArtMatcher::GetMatchingArtFromLayerList ( AILayerList  layerList  ) 
ai::int32 ai::ArtMatcher::GetNumMatches (  )  const

Returns the number of art objects matched by last GetMatchingArt() or GetSelectedArt() call.

AIErr ai::ArtMatcher::GetSelectedArt (  ) 
AIErr ai::ArtMatcher::GetSelectedArtFromLayerList ( AILayerList  layerList  ) 
ai::ArtMatcher::operator bool (  )  const [inline, explicit]

Check if the last query has some interesting data.

ArtMatcher & ai::ArtMatcher::operator= ( ArtMatcher &&  other  ) 

Move Assignment.

ArtMatcher& ai::ArtMatcher::operator= ( const ArtMatcher  ) 

Assignment is not allowed.

AIArtHandle ai::ArtMatcher::operator[] ( size_t  iX  )  const

References GetMatchedArt().

AIErr ai::ArtMatcher::PushSpec ( ai::int16  shType,
ai::int32  lWhichAttr,
ai::int32  lAttr 
)

Add spec to the end.

References kMatchDictionaryArt, kNoErr, and kOutOfMemoryErr.

reverse_iterator ai::ArtMatcher::rbegin (  )  const [inline]

References end().

AIArtHandle ** ai::ArtMatcher::release (  ) 

Transfer the ownership of stored art handles, call it only if you know what you are doing.

reverse_iterator ai::ArtMatcher::rend (  )  const [inline]

References begin().

AIErr ai::ArtMatcher::SetSpec ( size_t  iX,
ai::int16  shType,
ai::int32  lWhichAttr,
ai::int32  lAttr 
)

Set spec if size is already allocated.

References kMatchDictionaryArt, and kNoErr.


The documentation for this class was generated from the following files:


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