WPILibC++ 2023.4.3
Topic Functions

Functions

NT_TopicNT_GetTopics (NT_Inst inst, const char *prefix, size_t prefix_len, unsigned int types, size_t *count)
 Get Published Topic Handles. More...
 
NT_TopicNT_GetTopicsStr (NT_Inst inst, const char *prefix, size_t prefix_len, const char *const *types, size_t types_len, size_t *count)
 Get Published Topic Handles. More...
 
struct NT_TopicInfoNT_GetTopicInfos (NT_Inst inst, const char *prefix, size_t prefix_len, unsigned int types, size_t *count)
 Get Topics. More...
 
struct NT_TopicInfoNT_GetTopicInfosStr (NT_Inst inst, const char *prefix, size_t prefix_len, const char *const *types, size_t types_len, size_t *count)
 Get Topics. More...
 
NT_Bool NT_GetTopicInfo (NT_Topic topic, struct NT_TopicInfo *info)
 Gets Topic Information. More...
 
NT_Topic NT_GetTopic (NT_Inst inst, const char *name, size_t name_len)
 Gets Topic Handle. More...
 
char * NT_GetTopicName (NT_Topic topic, size_t *name_len)
 Gets the name of the specified topic. More...
 
enum NT_Type NT_GetTopicType (NT_Topic topic)
 Gets the type for the specified topic, or unassigned if non existent. More...
 
char * NT_GetTopicTypeString (NT_Topic topic, size_t *type_len)
 Gets the type string for the specified topic. More...
 
void NT_SetTopicPersistent (NT_Topic topic, NT_Bool value)
 Sets the persistent property of a topic. More...
 
NT_Bool NT_GetTopicPersistent (NT_Topic topic)
 Gets the persistent property of a topic. More...
 
void NT_SetTopicRetained (NT_Topic topic, NT_Bool value)
 Sets the retained property of a topic. More...
 
NT_Bool NT_GetTopicRetained (NT_Topic topic)
 Gets the retained property of a topic. More...
 
NT_Bool NT_GetTopicExists (NT_Handle handle)
 Determine if topic exists (e.g. More...
 
char * NT_GetTopicProperty (NT_Topic topic, const char *name, size_t *len)
 Gets the current value of a property (as a JSON string). More...
 
NT_Bool NT_SetTopicProperty (NT_Topic topic, const char *name, const char *value)
 Sets a property value. More...
 
void NT_DeleteTopicProperty (NT_Topic topic, const char *name)
 Deletes a property. More...
 
char * NT_GetTopicProperties (NT_Topic topic, size_t *len)
 Gets all topic properties as a JSON string. More...
 
NT_Bool NT_SetTopicProperties (NT_Topic topic, const char *properties)
 Updates multiple topic properties. More...
 
NT_Subscriber NT_Subscribe (NT_Topic topic, enum NT_Type type, const char *typeStr, const struct NT_PubSubOptions *options)
 Creates a new subscriber to value changes on a topic. More...
 
void NT_Unsubscribe (NT_Subscriber sub)
 Stops subscriber. More...
 
NT_Publisher NT_Publish (NT_Topic topic, enum NT_Type type, const char *typeStr, const struct NT_PubSubOptions *options)
 Creates a new publisher to a topic. More...
 
NT_Publisher NT_PublishEx (NT_Topic topic, enum NT_Type type, const char *typeStr, const char *properties, const struct NT_PubSubOptions *options)
 Creates a new publisher to a topic. More...
 
void NT_Unpublish (NT_Handle pubentry)
 Stops publisher. More...
 
NT_Entry NT_GetEntryEx (NT_Topic topic, enum NT_Type type, const char *typeStr, const struct NT_PubSubOptions *options)
 Creates a new entry (subscriber and weak publisher) to a topic. More...
 
void NT_ReleaseEntry (NT_Entry entry)
 Stops entry subscriber/publisher. More...
 
void NT_Release (NT_Handle pubsubentry)
 Stops entry/subscriber/publisher. More...
 
NT_Topic NT_GetTopicFromHandle (NT_Handle pubsubentry)
 Gets the topic handle from an entry/subscriber/publisher handle. More...
 

Detailed Description

Function Documentation

◆ NT_DeleteTopicProperty()

void NT_DeleteTopicProperty ( NT_Topic  topic,
const char *  name 
)

Deletes a property.

Has no effect if the property does not exist.

Parameters
topictopic handle
nameproperty name

◆ NT_GetEntryEx()

NT_Entry NT_GetEntryEx ( NT_Topic  topic,
enum NT_Type  type,
const char *  typeStr,
const struct NT_PubSubOptions options 
)

Creates a new entry (subscriber and weak publisher) to a topic.

Parameters
topictopic handle
typetype
typeStrtype string
optionspublish options
Returns
Entry handle

◆ NT_GetTopic()

NT_Topic NT_GetTopic ( NT_Inst  inst,
const char *  name,
size_t  name_len 
)

Gets Topic Handle.

Returns topic handle.

Parameters
instinstance handle
nametopic name
name_lenlength of topic name in bytes
Returns
Topic handle.

◆ NT_GetTopicExists()

NT_Bool NT_GetTopicExists ( NT_Handle  handle)

Determine if topic exists (e.g.

has at least one publisher).

Parameters
handleTopic, entry, or subscriber handle.
Returns
True if topic exists.

◆ NT_GetTopicFromHandle()

NT_Topic NT_GetTopicFromHandle ( NT_Handle  pubsubentry)

Gets the topic handle from an entry/subscriber/publisher handle.

Parameters
pubsubentryentry/subscriber/publisher handle
Returns
Topic handle

◆ NT_GetTopicInfo()

NT_Bool NT_GetTopicInfo ( NT_Topic  topic,
struct NT_TopicInfo info 
)

Gets Topic Information.

Returns information about a topic (name and type).

Parameters
topichandle
infoinformation (output)
Returns
True if successful, false on error.

◆ NT_GetTopicInfos()

struct NT_TopicInfo * NT_GetTopicInfos ( NT_Inst  inst,
const char *  prefix,
size_t  prefix_len,
unsigned int  types,
size_t *  count 
)

Get Topics.

Returns an array of topic information (handle, name, type). The results are optionally filtered by string prefix and type to only return a subset of all topics.

Parameters
instinstance handle
prefixname required prefix; only topics whose name starts with this string are returned
prefix_lenlength of prefix in bytes
typesbitmask of NT_Type values; 0 is treated specially as a "don't care"
countoutput parameter; set to length of returned array
Returns
Array of topic information.

◆ NT_GetTopicInfosStr()

struct NT_TopicInfo * NT_GetTopicInfosStr ( NT_Inst  inst,
const char *  prefix,
size_t  prefix_len,
const char *const *  types,
size_t  types_len,
size_t *  count 
)

Get Topics.

Returns an array of topic information (handle, name, type). The results are optionally filtered by string prefix and type to only return a subset of all topics.

Parameters
instinstance handle
prefixname required prefix; only topics whose name starts with this string are returned
prefix_lenlength of prefix in bytes
typesarray of type strings
types_lennumber of elements in types array
countoutput parameter; set to length of returned array
Returns
Array of topic information.

◆ NT_GetTopicName()

char * NT_GetTopicName ( NT_Topic  topic,
size_t *  name_len 
)

Gets the name of the specified topic.

Parameters
topictopic handle
name_lenlength of topic name (output)
Returns
Topic name; returns NULL and name_len=0 if the handle is invalid.

◆ NT_GetTopicPersistent()

NT_Bool NT_GetTopicPersistent ( NT_Topic  topic)

Gets the persistent property of a topic.

Parameters
topictopic handle
Returns
persistent property value

◆ NT_GetTopicProperties()

char * NT_GetTopicProperties ( NT_Topic  topic,
size_t *  len 
)

Gets all topic properties as a JSON string.

Each key in the object is the property name, and the corresponding value is the property value.

Parameters
topictopic handle
lenlength of returned string (output)
Returns
JSON string

◆ NT_GetTopicProperty()

char * NT_GetTopicProperty ( NT_Topic  topic,
const char *  name,
size_t *  len 
)

Gets the current value of a property (as a JSON string).

Parameters
topictopic handle
nameproperty name
lenlength of returned string (output)
Returns
JSON string; empty string if the property does not exist.

◆ NT_GetTopicRetained()

NT_Bool NT_GetTopicRetained ( NT_Topic  topic)

Gets the retained property of a topic.

Parameters
topictopic handle
Returns
retained property value

◆ NT_GetTopics()

NT_Topic * NT_GetTopics ( NT_Inst  inst,
const char *  prefix,
size_t  prefix_len,
unsigned int  types,
size_t *  count 
)

Get Published Topic Handles.

Returns an array of topic handles. The results are optionally filtered by string prefix and type to only return a subset of all topics.

Parameters
instinstance handle
prefixname required prefix; only topics whose name starts with this string are returned
prefix_lenlength of prefix in bytes
typesbitmask of NT_Type values; 0 is treated specially as a "don't care"
countoutput parameter; set to length of returned array
Returns
Array of topic handles.

◆ NT_GetTopicsStr()

NT_Topic * NT_GetTopicsStr ( NT_Inst  inst,
const char *  prefix,
size_t  prefix_len,
const char *const *  types,
size_t  types_len,
size_t *  count 
)

Get Published Topic Handles.

Returns an array of topic handles. The results are optionally filtered by string prefix and type to only return a subset of all topics.

Parameters
instinstance handle
prefixname required prefix; only topics whose name starts with this string are returned
prefix_lenlength of prefix in bytes
typesarray of type strings
types_lennumber of elements in types array
countoutput parameter; set to length of returned array
Returns
Array of topic handles.

◆ NT_GetTopicType()

enum NT_Type NT_GetTopicType ( NT_Topic  topic)

Gets the type for the specified topic, or unassigned if non existent.

Parameters
topictopic handle
Returns
Topic type

◆ NT_GetTopicTypeString()

char * NT_GetTopicTypeString ( NT_Topic  topic,
size_t *  type_len 
)

Gets the type string for the specified topic.

This may have more information than the numeric type (especially for raw values).

Parameters
topictopic handle
type_lenlength of type string (output)
Returns
Topic type string; returns NULL if non-existent

◆ NT_Publish()

NT_Publisher NT_Publish ( NT_Topic  topic,
enum NT_Type  type,
const char *  typeStr,
const struct NT_PubSubOptions options 
)

Creates a new publisher to a topic.

Parameters
topictopic handle
typetype
typeStrtype string
optionspublish options
Returns
Publisher handle

◆ NT_PublishEx()

NT_Publisher NT_PublishEx ( NT_Topic  topic,
enum NT_Type  type,
const char *  typeStr,
const char *  properties,
const struct NT_PubSubOptions options 
)

Creates a new publisher to a topic.

Parameters
topictopic handle
typetype
typeStrtype string
propertiesinitial properties (JSON object)
optionspublish options
Returns
Publisher handle

◆ NT_Release()

void NT_Release ( NT_Handle  pubsubentry)

Stops entry/subscriber/publisher.

Parameters
pubsubentryentry/subscriber/publisher handle

◆ NT_ReleaseEntry()

void NT_ReleaseEntry ( NT_Entry  entry)

Stops entry subscriber/publisher.

Parameters
entryentry handle

◆ NT_SetTopicPersistent()

void NT_SetTopicPersistent ( NT_Topic  topic,
NT_Bool  value 
)

Sets the persistent property of a topic.

If true, the stored value is persistent through server restarts.

Parameters
topictopic handle
valueTrue for persistent, false for not persistent.

◆ NT_SetTopicProperties()

NT_Bool NT_SetTopicProperties ( NT_Topic  topic,
const char *  properties 
)

Updates multiple topic properties.

Each key in the passed-in JSON object is the name of the property to add/update, and the corresponding value is the property value to set for that property. Null values result in deletion of the corresponding property.

Parameters
topictopic handle
propertiesJSON object string with keys to add/update/delete
Returns
False if properties are not a valid JSON object

◆ NT_SetTopicProperty()

NT_Bool NT_SetTopicProperty ( NT_Topic  topic,
const char *  name,
const char *  value 
)

Sets a property value.

Parameters
topictopic handle
nameproperty name
valueproperty value (JSON string)

◆ NT_SetTopicRetained()

void NT_SetTopicRetained ( NT_Topic  topic,
NT_Bool  value 
)

Sets the retained property of a topic.

If true, the server retains the topic even when there are no publishers.

Parameters
topictopic handle
valuenew retained property value

◆ NT_Subscribe()

NT_Subscriber NT_Subscribe ( NT_Topic  topic,
enum NT_Type  type,
const char *  typeStr,
const struct NT_PubSubOptions options 
)

Creates a new subscriber to value changes on a topic.

Parameters
topictopic handle
typeexpected type
typeStrexpected type string
optionssubscription options
Returns
Subscriber handle

◆ NT_Unpublish()

void NT_Unpublish ( NT_Handle  pubentry)

Stops publisher.

Parameters
pubentrypublisher/entry handle

◆ NT_Unsubscribe()

void NT_Unsubscribe ( NT_Subscriber  sub)

Stops subscriber.

Parameters
subsubscriber handle