Skip to content

EMP Object Reference

Alex Dean edited this page Jun 24, 2013 · 1 revision

There are a few objects that EMP has, which the DB will need to know about and how to store. This is subject to change while in pre-alpha, and should probably be in the EMPD wiki (but for now, this will do). You can find more information about these in empinternal.hrl and emptypes.hrl.


EMPUSER

-record(user, 
        {
          uid         :: 'UUID'(),
          name=(<<>>) :: 'BINARYSTRING'() %Note: default required.
        }).
-type 'EMPUSER'() :: #user{}.
-define(EMPUSER( UID, NAME ),
        #user{
            uid=UID,
            name=NAME
        }).

EMPPARAM

-record(param, 
        { 
          name    :: 'BINARYSTRING'(),
          default :: json_valid_value(), 
          type    :: 'EMPTYPEDEF'()
        }).
-type 'EMPPARAM'() :: #param{}.
-define(EMPPARAM(Name, TypeDef, Default), 
            #param{name=Name,
                   type=TypeDef, 
                   default=Default}).

EMPEVENT

-record(event, 
        {
          pid :: 'UUID'(),
          eid :: 'UUID'(),
          name :: 'BINARYSTRING'(),
          dvalues=[] :: ['EMPPARAM'()] 
        }).
-type 'EMPEVENT'() :: #command{}.
-define(EMPEVENT(Name, ValueList),
            #event{name=Name, 
                   dvalues=ValueList}).

EMPCOMMAND

-record(command,
        {
          pid  :: 'UUID'(),
          cid  :: 'UUID'(),
          name :: 'BINARYSTRING'(),
          func :: fun(),
          dparams=[] :: ['EMPPARAM'()],
          rettype :: 'EMPTYPEDEF'()
        }).
-type 'EMPCOMMAND'() :: #command{}.
-define(EMPCOMMAND(Name, Function, ParamList, RetList), 
            #command{name=Name, 
                     func=Function, 
                     dparams=ParamList, 
                     rettype=RetList}).

EMPPLUGINDEF

-record(plugindef,
        {
         id        :: 'UUID'(),
         module    :: atom(),
         state     :: [ { 'BINARYSTRING'(), any() } ],
         commands  :: 'EMPCOMMAND'()
        }).
-type 'EMPPLUGINDEF'() :: #plugindef{}.
-define(EMPPLUGINDEF(ID, MODULE, STATE, COMMANDS ),
        #plugindef{
            id = ID,
            module = MODULE,
            state = STATE,
            commands = COMMANDS
        }).

EMPSUBSCRIPTION

-record(subscription, 
        {
          event :: 'EMPEVENT'(),
          command :: 'EMPCOMMAND'(),
          temp=false :: boolean(),
          mapping=[] :: [tuple()]
        }).
-type 'EMPSUBSCRIPTION'() :: #subscription{}.
-define(EMPSUBSCRIPTION(EVENT,COMMAND,MAPPING),
       #subscription{
          event=EVENT,
          command=COMMAND,
          mapping=MAPPING           
       }).

Clone this wiki locally