summaryrefslogtreecommitdiff
path: root/core/pla_getbyname.hpp
blob: 30f2db03276883d08e1f5ca9c4cb2417237b3e04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef fwzTcntkbxdRjyBO90weDhBZ4Nc
#define fwzTcntkbxdRjyBO90weDhBZ4Nc

#include <string.h>

#include "template_helpers.hpp"

// PLA template
template<template<typename Prop, typename QuantClass> class Payload, 
	 typename BaseCase = Payload<BaseCase, Void>>
struct PLA_GetByName {
  // action types & consts
  typedef BaseCase* result_t;
  template<typename ContextProp, bool doWriteResults> struct local_state_t {
    typedef ContextProp prop;
  };

  // action state
  char *name;
  result_t result;

  PLA_GetByName(char *name) : name(name), result(NULL) {}

  // action methods
  template<typename _PropList, typename _ContextData, typename LocalState>
  inline void pre(_PropList &pc, _ContextData &data, LocalState &state) {
    typedef typename LocalState::prop Prop;
    if (strcmp(Prop::name, name) == 0) {
      result = new Payload<Prop, typename Prop::quant::class_t>();
    }
  }

  template<typename _PropComp, typename _Data, typename _LocalState>
  inline void post(_PropComp &, _Data &, _LocalState &) { }
};

#endif // fwzTcntkbxdRjyBO90weDhBZ4Nc
contact: Jan Huwald // Impressum