diff --git a/v4/cli.cpp b/v4/cli.cpp index cdd8a91..0090eef 100644 --- a/v4/cli.cpp +++ b/v4/cli.cpp @@ -1,6 +1,8 @@ + #include #include #include +#include "ctx.h" #include "llm.h" #include "memory_Context.h" #include "main.h" diff --git a/v4/cli_test.cpp b/v4/cli_test.cpp index c24f5bd..83c1a18 100644 --- a/v4/cli_test.cpp +++ b/v4/cli_test.cpp @@ -1,6 +1,8 @@ + #include #include #include +#include "ctx.h" #include "llm.h" #include "memory_Context.h" #include "main.h" diff --git a/v4/ctx.h b/v4/ctx.h new file mode 100644 index 0000000..907225f --- /dev/null +++ b/v4/ctx.h @@ -0,0 +1,15 @@ +#include +#include + +#ifndef ctx_HEADER +#define ctx_HEADER + +template class ctx_Controller { + T context; + + ctx_Controller(const T &c) { + context = c; + } +}; + +#endif // ctx_HEADER diff --git a/v4/Controller.py b/v4/ctx.py similarity index 98% rename from v4/Controller.py rename to v4/ctx.py index 21a85e7..76ad2cb 100644 --- a/v4/Controller.py +++ b/v4/ctx.py @@ -1,6 +1,6 @@ import copy -class Controller: +class ctx_Controller: def __init__(self, c): self.callbacks = [] self.context = c diff --git a/v4/llm_test.cpp b/v4/llm_test.cpp index a0049ba..5dcc3d3 100644 --- a/v4/llm_test.cpp +++ b/v4/llm_test.cpp @@ -1,6 +1,8 @@ + #include #include #include +#include "ctx.h" #include "llm.h" #include "memory_Context.h" #include "main.h" diff --git a/v4/main.py b/v4/main.py index d028108..c97f108 100644 --- a/v4/main.py +++ b/v4/main.py @@ -1,9 +1,9 @@ from cli import * from cli_test import * +from ctx import * from llm_test import * from llm_test_Python import * from memory_test import * -from Controller import * import sys print(llm_test_Python_copyByValue()) @@ -35,7 +35,7 @@ print(cli_test_reportMatchedItems()) print(cli_test_reportMismatchedItems()) print(cli_test_reportVictory()) -ctrl = Controller(memory_createContext()) +ctrl = ctx_Controller(memory_createContext()) ctrl.registerFunctions([ cli_exit, cli_goOn, diff --git a/v4/memory.cpp b/v4/memory.cpp index 7b731cf..0448251 100644 --- a/v4/memory.cpp +++ b/v4/memory.cpp @@ -1,6 +1,8 @@ + #include #include #include +#include "ctx.h" #include "llm.h" #include "memory_Context.h" #include "main.h" diff --git a/v4/memory_Context.cpp b/v4/memory_Context.cpp index d21fb82..cd3ce1c 100644 --- a/v4/memory_Context.cpp +++ b/v4/memory_Context.cpp @@ -1,5 +1,24 @@ #include "memory_Context.h" + +template T memory_Context::field(const std::string &fieldName) { + if (fieldName == "didLaunch") { + return didLaunch; + } + + // TODO + + return 0; +} + +template void memory_Context::setField(const std::string &fieldName, T value) { + if (fieldName == "didLaunch") { + didLaunch = value; + } + + // TODO +} + memory_Context memory_createContext() { return memory_Context(); } diff --git a/v4/memory_Context.h b/v4/memory_Context.h index 16bd33e..ea99ff3 100644 --- a/v4/memory_Context.h +++ b/v4/memory_Context.h @@ -1,6 +1,7 @@ #include #include #include +#include "ctx.h" #ifndef memory_Context_HEADER #define memory_Context_HEADER @@ -11,6 +12,7 @@ struct memory_Context { std::string input = ""; std::vector hiddenItems; std::vector mismatchedItems; + std::string recentField = "none"; std::string outputGoOn = ""; std::string outputGreeting = ""; std::string outputHelp = ""; @@ -20,10 +22,12 @@ struct memory_Context { std::string outputVictory = ""; std::map playfieldItems; int playfieldSize = 0; - std::string recentField = "none"; int selectedId = -1; std::vector selectedItems; bool victory = false; + + template T field(const std::string &fieldName); + template void setField(const std::string &fieldName, T value); }; memory_Context memory_createContext(); diff --git a/v4/memory_test.cpp b/v4/memory_test.cpp index 5936364..e6d9a99 100644 --- a/v4/memory_test.cpp +++ b/v4/memory_test.cpp @@ -1,6 +1,8 @@ + #include #include #include +#include "ctx.h" #include "llm.h" #include "memory_Context.h" #include "main.h" diff --git a/v4/tPythonC++/CPP.py b/v4/tPythonC++/CPP.py index 7516839..364f7cd 100644 --- a/v4/tPythonC++/CPP.py +++ b/v4/tPythonC++/CPP.py @@ -1,9 +1,11 @@ from Function import * def includes(): - return """#include + return """ +#include #include #include +#include "ctx.h" #include "llm.h" #include "memory_Context.h" #include "main.h"