Server Tags

From The Foundry MODO SDK wiki
Revision as of 19:23, 26 February 2012 by Shf (Talk | contribs) (Standard Tags)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Plug-in servers are self-describing. The first aspect of their identity is their server class and name. The class indicates what function they perform (Loader, Saver, Command, etc.) and the name uniquely identifies that server among all servers of the same class.

The second part of the self-description are the server tags. A tag is a pair of strings that are the name & value of some attribute, and each server can support multiple tag attributes. Although tags are read from servers the first time they are loaded, they are also cached in the config file. This allows nexus to keep track of the attributes of servers so that they can remain unloaded until absolutely required.

Standard Tags

All servers support some command tags. The LXsSRV_USERNAME tag can give a human-readable version of the internal name. This is something of a legacy tag since it doesn't allow for internationalization, making it suitable only for names that don't need translation, like proper names.

The LXsSRV_LICENSE tag can give a value for a license required to load the plug-in. This is a license in nexus format, so it requires a contract with Luxology to generate appropriate licenses. See the reference docs for details.

The LXsSRV_LOGSUBSYSTEM tag indicates the name or names of log subsystems that will be used for output from the server.

All other tags are specific to the server class. See the overview for each server type for details on available tags.

Declaring Tags

StaticDesc Implementation

Tags can be most easily added by defining a descInfo array in the C++ server class:

class CMyLoader
        static LXtTagInfoDesc	 descInfo[];

The contents of the array must be declaring statically, and is terminated with a null name:

LXtTagInfoDesc	 CMyLoader::descInfo[] = {
        { LXsSRV_USERNAME,	"Ultra JPEG"	},
        { LXsSAV_DOSPATTERN,	"*.jpg;*.jpeg"	},
        { 0 }

Finally the server polymorph wrapper has to implement the StaticDesc implementation.

        srv->AddInterface (new CLxIfc_StaticDesc<CMyLoader>);
TagDescription Implementation

The StaticDesc wrapper actually works by adding a TagDescription Interface to the server's exported interfaces. This can be done directly instead of using the static array wrapper.

class CMyLoader :
        public CLxImpl_TagDescription
        unsigned      tag_Count ()                                 LXx_OVERRIDE;
        LxResult      tag_Describe (unsigned, LXtTagInfoDesc *)    LXx_OVERRIDE;

The Count() method returns the number of tags, and the Describe() method returns the tag/value pairs by index.

CMyLoader::tag_Count ()
        return 2;

CMyLoader::tag_Describe (
        unsigned		 index,
        LXtTagInfoDesc		*desc)
        if (index == 0) {
                desc.type = LXsSAV_CLASSLIST;
       = LXa_IMAGE;
        } else if (index == 1)
                desc.type = LXsSAV_DOSPATTERN;
       = "*.jpg;*.jpeg";
        } else
                return LXe_OUTOFBOUNDS;

        return LXe_OK;

Per usual the interface has to be presented by the polymorph.

        srv->AddInterface (new CLxIfc_TagDescription<CMyLoader>);