Skip to main content
July 13, 2011
Answered

Newbie - Boss classes and interfaces

  • July 13, 2011
  • 1 reply
  • 1003 views

I'm currently going through Kris Coppieters' "Adobe InDesign CS3/CS4 SDK Programming Getting Started" book and I'm stuck at one of the exercise (11.9) It asks me to create a new boss 'kIDSDKTrainerBoss' which aggregates 2 interfaces 'ISDKTrainerName' and 'ISDKTrainerBlob'.

Now here is what I added in my .fr file:

Class
    {
        kIDSDKTrainerBoss,
          kDialogBoss,
        {
            IID_ISDKTRAINERNAME, kISDKTrainerNameImpl,
            IID_ISDKTRAINERBLOB, kISDKTrainerBlobImpl,
        }
    },

  1. First of all I'm not quite sure about the interface IDs. Are IID_ISDKTRAINERNAME and IID_ISDKTRAINERBLOB suitable?
  2. What are the files that I need to create? I guess there will be a ISDKTrainerName.cpp and ISDKTrainerBlob.cpp but apart from those?
  3. How to know which parent Boss ID to use? Here I've put kDialogBoss, but that was just to mimic the other bosses in the .fr file.
  4. Is there somewhere where I can get the source code with the solution, it's not in the zip file provided along with the book?

Thanks in advance for your help
-- Bastien
This topic has been closed for replies.
Correct answer RorohikoKris

Hi Bastien,

Instead of using kDialogBoss, you should use kInvalidClass. That means 'this boss does not have a superclass at all' - making it a 'root boss class', which does not inherit from anything.

The goal of the exercise is to build a totally new, detached boss class - something that's not tied into any other boss classes in the InDesign ecosystem.

The interface IDs are whatever you want to make them - the ones you have there are fine, but you can make something else up. The main thing is to try and follow the convention - but also realize that it's only convention. If you wanted to you could use IID_BOBTHEBUILDER and IID_THOMASTHETANKENGINE. By convention, you'd then probably name the implementations kBobTheBuilderImpl and kThomasTheTankEngineImpl

Define those IDs in your ...ID.h file - they're yours, and you're the master and decider of how you call them - whether it's IID_ISDKTRAINERNAME or IID_BOBTHEBUILDER.

For a clue on the source code file names - look at the figure on page 120 - that sample uses IID_ISOMETHING and IID_ISOMETHINGOTHER as 'silly' names, and also shows the names of the source code files that by convention would go with them.

Cheers,

Kris

1 reply

RorohikoKrisCorrect answer
Inspiring
July 13, 2011

Hi Bastien,

Instead of using kDialogBoss, you should use kInvalidClass. That means 'this boss does not have a superclass at all' - making it a 'root boss class', which does not inherit from anything.

The goal of the exercise is to build a totally new, detached boss class - something that's not tied into any other boss classes in the InDesign ecosystem.

The interface IDs are whatever you want to make them - the ones you have there are fine, but you can make something else up. The main thing is to try and follow the convention - but also realize that it's only convention. If you wanted to you could use IID_BOBTHEBUILDER and IID_THOMASTHETANKENGINE. By convention, you'd then probably name the implementations kBobTheBuilderImpl and kThomasTheTankEngineImpl

Define those IDs in your ...ID.h file - they're yours, and you're the master and decider of how you call them - whether it's IID_ISDKTRAINERNAME or IID_BOBTHEBUILDER.

For a clue on the source code file names - look at the figure on page 120 - that sample uses IID_ISOMETHING and IID_ISOMETHINGOTHER as 'silly' names, and also shows the names of the source code files that by convention would go with them.

Cheers,

Kris

July 14, 2011

Thank you Kris. Getting a few step further ;-)