Add example interfaces

Add example interfaces for testing.
Add a script that generates sdbusplus bindings for example interfaces.

Change-Id: I683ce9dca74d827d226833ed8a56f87243914e04
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/example/events/match2.yaml b/example/events/match2.yaml
index db10099..4bf2ddd 100644
--- a/example/events/match2.yaml
+++ b/example/events/match2.yaml
@@ -9,14 +9,14 @@
       type: match
       signature:
           type: signal
-          path: /xyz/openbmc_project/testing
+          path: /xyz/openbmc_project/Inventory/example
           interface: org.freedesktop.DBus.Properties
           member: PropertiesChanged
       filter:
           type: propertyChangedTo
           args:
-            - value: xyz.openbmc_project.Testing
-            - value: TestProperty
+            - value: xyz.openbmc_project.Example.Iface1
+            - value: ExampleProperty1
             - value: teststring
       action:
           type: destroyObject("Example")
diff --git a/example/interfaces.yaml b/example/interfaces.yaml
new file mode 100644
index 0000000..56b6198
--- /dev/null
+++ b/example/interfaces.yaml
@@ -0,0 +1,2 @@
+- xyz.openbmc_project.Example.Iface1
+- xyz.openbmc_project.Example.Iface2
diff --git a/example/interfaces/xyz/openbmc_project/Example/Iface1.interface.yaml b/example/interfaces/xyz/openbmc_project/Example/Iface1.interface.yaml
new file mode 100644
index 0000000..5d11fd1
--- /dev/null
+++ b/example/interfaces/xyz/openbmc_project/Example/Iface1.interface.yaml
@@ -0,0 +1,9 @@
+description: >
+    Example interface for PIM.
+properties:
+    - name: ExampleProperty1
+      type: std::string
+      description: >
+          An example property.
+
+# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
diff --git a/example/interfaces/xyz/openbmc_project/Example/Iface2.interface.yaml b/example/interfaces/xyz/openbmc_project/Example/Iface2.interface.yaml
new file mode 100644
index 0000000..09047a8
--- /dev/null
+++ b/example/interfaces/xyz/openbmc_project/Example/Iface2.interface.yaml
@@ -0,0 +1,9 @@
+description: >
+    Example interface for PIM.
+properties:
+    - name: ExampleProperty2
+      type: std::string
+      description: >
+          An example property.
+
+# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
diff --git a/make_example.py b/make_example.py
new file mode 100755
index 0000000..33e7fcb
--- /dev/null
+++ b/make_example.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import yaml
+import subprocess
+
+
+class SDBUSPlus(object):
+    def __init__(self, path):
+        self.path = path
+
+    def __call__(self, *a, **kw):
+        args = [
+            os.path.join(self.path,  'sdbus++'),
+            '-t',
+            os.path.join(self.path, 'templates')
+        ]
+
+        subprocess.call(args + list(a), **kw)
+
+
+if __name__ == '__main__':
+    sdbusplus = None
+    for p in os.environ.get('PATH', "").split(os.pathsep):
+        if os.path.exists(os.path.join(p, 'sdbus++')):
+            sdbusplus = SDBUSPlus(p)
+            break
+
+    if sdbusplus is None:
+        sys.stderr.write('Cannot find sdbus++\n')
+        sys.exit(1)
+
+    genfiles = {
+        'server-cpp': lambda x: '%s.cpp' % x,
+        'server-header': lambda x: os.path.join(
+            os.path.join(*x.split('.')), 'server.hpp')
+    }
+    with open(os.path.join('example', 'interfaces.yaml'), 'r') as fd:
+        interfaces = yaml.load(fd.read())
+
+    for i in interfaces:
+        for process, f in genfiles.iteritems():
+
+            dest = f(i)
+            parent = os.path.dirname(dest)
+            if parent and not os.path.exists(parent):
+                os.makedirs(parent)
+
+            with open(dest, 'w') as fd:
+                sdbusplus(
+                    '-r',
+                    os.path.join('example', 'interfaces'),
+                    'interface',
+                    process,
+                    i,
+                    stdout=fd)
+
+# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4