Author Topic: How do I get at the frame range that is associated with a job in C++?  (Read 4931 times)

methodhai

  • Sr. Member
  • ****
  • Posts: 28
What is the recommended to get at the frame range that is associated with a job?

Also, I noticed that the member _data for QbJob has the cmdline, padding, etc values in it - how would I go about accessing data in the blessed Qube way?

Thanks,
Hai
« Last Edit: November 30, 2007, 09:43:52 PM by anthony »

anthony

  • Senior Software Engineer
  • Hero Member
  • *****
  • Posts: 183
Re: frame number
« Reply #1 on: November 30, 2007, 04:00:07 AM »
Hey methodhai,

    This depends on which api you're using.  Is it C++?

     A.

methodhai

  • Sr. Member
  • ****
  • Posts: 28
Re: frame number
« Reply #2 on: November 30, 2007, 04:06:02 AM »
Yes, C++.

methodhai

  • Sr. Member
  • ****
  • Posts: 28
Re: frame number
« Reply #3 on: November 30, 2007, 08:13:52 PM »
I just (re)discovered that the name field in QbWork corresponds to the frame numbers.

However, I'm still curious as to how to get cmdline and padding....?

Thanks,
Hai

anthony

  • Senior Software Engineer
  • Hero Member
  • *****
  • Posts: 183
Re: frame number
« Reply #4 on: November 30, 2007, 09:42:09 PM »
Hey Methodhai,

    Here is a good snippit of example code to help you out:

    We'll assume you're using the QbJob object.  I'll use a pointer instance, since I know you're probably using a query.

        // Note: the job object pointer normally comes from iterating through
        //  a standard job query.  Please refer to previous forum posts for information
        QbJob *job = new QbJob();

        //  We'll use the following string objects to catch the results we want.
        QbString cmdline;
        QbString padding;
        QbString shell;

        //  Note: the package libraries are pure "ANSI C" libs, there are C++ objects
        //    which do package decoding as well, however I'll use the C libs
        //    for this example

        // Expand the package encoded in the job's data method
        qb_package *pck = qb_package_expand((QB_CHAR*) job->data().value());

        // since we know it's a hash of data, we'll just iterate through each
        // hash element (hash, dictionary... same thing)
        for (QB_INT i = 0; i < qb_package_list_len(pck); i++) {
                qb_package *item = qb_package_list_get(pck, i);
                QbString name(qb_package_get_name(item));
                if (name == "cmdline") {
                        cmdline = qb_package_get_value(item);
                } else if (name == "padding") {
                        padding = qb_package_get_value(item);
                } else if (name == "shell") {
                        shell = qb_package_get_value(item);
                }
        }

        // ANSI C doesn't give you destructors... so we need to do it ourselves.
        qb_package_destroy(pck);

        // Here we'll show you how to take the job's agenda, and use the Qube!
        // range analysis object to get the compressed form of the range
        // (ex. 1-100x10)

        QbRange collection;
        for (QB_INT i = 0; i < job->agenda().length(); i++) {
                QbWork* work = job->agenda().get(i);
                if (work == NULL)
                        continue;

                collection.add(work->name());
        }

        QbString range = collection.value();


   I hope this is everything you need.  Let us know if you have anything else.

         A.

methodhai

  • Sr. Member
  • ****
  • Posts: 28
Re: How do I get at the frame range that is associated with a job in C++?
« Reply #5 on: December 05, 2007, 10:04:38 PM »
Hi Anthony,

Thanks for the reply. Just another question about this part:
        // Here we'll show you how to take the job's agenda, and use the Qube!
        // range analysis object to get the compressed form of the range
        // (ex. 1-100x10)

        QbRange collection;
        for (QB_INT i = 0; i < job->agenda().length(); i++) {
                QbWork* work = job->agenda().get(i);
                if (work == NULL)
                        continue;

                collection.add(work->name());
        }

        QbString range = collection.value();


It seems that QbRange::add doesn't have an overload to take a QbString that is being handed back by QbWork.

Do I use the QbRange::parse method instead?

anthony

  • Senior Software Engineer
  • Hero Member
  • *****
  • Posts: 183
Re: How do I get at the frame range that is associated with a job in C++?
« Reply #6 on: December 05, 2007, 10:35:55 PM »
Gah... that's what I get for working off of Qube! 5.3's api set.  yes.  you can use the "parse" routine instead.  Although please keep in mind that the parse routine will change slightly from 5.2 to 5.3, if you can guarantee that your frames will be single integers, then you can do the following:

collection.add(work->name().integervalue());

for now, will work as well, but will be depricated completely with 5.3

collection.parse(work->name());




methodhai

  • Sr. Member
  • ****
  • Posts: 28
Re: How do I get at the frame range that is associated with a job in C++?
« Reply #7 on: December 05, 2007, 11:27:21 PM »
Thanks Anthony.

I have another question, but I'll start new thread since it's a bit unrelated.