git » fp-git.git » commit 077ec29

Some ideas for how to do resource management

author unlord
2004-07-07 14:34:28 UTC
committer unlord
2004-07-07 14:34:28 UTC
parent 1f5474dc876b19ca1ddf9de492010df963a6354d

Some ideas for how to do resource management

stuff/ideas/FPConfig.c +11 -0
stuff/ideas/FPConfig.h +12 -0
stuff/ideas/FPImage.c +2 -0
stuff/ideas/FPImage.h +15 -0
stuff/ideas/FPResource.c +5 -0
stuff/ideas/FPResource.h +12 -0
stuff/ideas/main.c +22 -0

diff --git a/stuff/ideas/FPConfig.c b/stuff/ideas/FPConfig.c
new file mode 100644
index 0000000..da6d628
--- /dev/null
+++ b/stuff/ideas/FPConfig.c
@@ -0,0 +1,11 @@
+#include <string.h>
+#include "FPConfig.h"
+
+int cfgInit(FPConfig *_this,char *_pop1_path) {
+  _this->pop1_path=(char *)malloc(strlen(_pop1_path)+1);
+  if (_this->pop1_path==NULL) {
+    return(0);
+  }
+  strcpy(_this->pop1_path,_pop1_path);
+  return(1);
+}
diff --git a/stuff/ideas/FPConfig.h b/stuff/ideas/FPConfig.h
new file mode 100644
index 0000000..128dbfa
--- /dev/null
+++ b/stuff/ideas/FPConfig.h
@@ -0,0 +1,12 @@
+#ifndef _FP_CONFIG_H
+#define _FP_CONFIG_H
+
+typedef struct FPConfig FPConfig;
+
+struct FPConfig {
+  char *pop1_path;
+};
+
+int cfgInit(FPConfig *_this,char *_pop1_path);
+
+#endif
diff --git a/stuff/ideas/FPImage.c b/stuff/ideas/FPImage.c
new file mode 100644
index 0000000..b3e483f
--- /dev/null
+++ b/stuff/ideas/FPImage.c
@@ -0,0 +1,2 @@
+#include "FPImage.h"
+
diff --git a/stuff/ideas/FPImage.h b/stuff/ideas/FPImage.h
new file mode 100644
index 0000000..867bd6e
--- /dev/null
+++ b/stuff/ideas/FPImage.h
@@ -0,0 +1,15 @@
+#ifndef _FP_IMAGE_H
+#define _FP_IMAGE_H
+
+typedef struct FPImage FPImage;
+
+/* FPImage is a FPResource for static images
+ */
+struct FPImage {
+  int id;
+  int height;
+  int width;
+  char *image;
+};
+
+#endif
diff --git a/stuff/ideas/FPResource.c b/stuff/ideas/FPResource.c
new file mode 100644
index 0000000..364eb7d
--- /dev/null
+++ b/stuff/ideas/FPResource.c
@@ -0,0 +1,5 @@
+#include "FPResource.h"
+
+int resGetId(FPResource *_this) {
+  return(_this->id);
+}
diff --git a/stuff/ideas/FPResource.h b/stuff/ideas/FPResource.h
new file mode 100644
index 0000000..e64c770
--- /dev/null
+++ b/stuff/ideas/FPResource.h
@@ -0,0 +1,12 @@
+#ifndef _FP_RESOURCE_H
+#define _FP_RESOURCE_H
+
+typedef struct FPResource FPResource;
+
+struct FPResource {
+  int id;
+};
+
+int resGetId(FPResource *_this);
+
+#endif
diff --git a/stuff/ideas/main.c b/stuff/ideas/main.c
new file mode 100644
index 0000000..da85d40
--- /dev/null
+++ b/stuff/ideas/main.c
@@ -0,0 +1,22 @@
+#include "FPConfig.h"
+#include "FPResourceManager.h"
+
+int main(int _argc,char *_argv[]) {
+  FPConfig config;
+
+  /* this should be loaded from a conf file on disk
+   */
+  if (!cfgInit(&config,"./")) {
+    /* print error message */
+    return(-1);
+  }
+
+  /* configure the resource manager */
+  if (!mgrInit(&config)) {
+    /* print error message */
+    return(-1);
+  }
+
+
+  return(0);
+}