-
Notifications
You must be signed in to change notification settings - Fork 1
Home

Smart_Store is a robust, extensible, and modular C++20 framework for managing collections of arbitrary objects with advanced serialization, schema migration, and undo/redo state management. It is ideal for inventory management, asset tracking, game editors, and any application needing flexible object storage with persistence and versioning.
Smart_Store isnβt just a C++ framework; itβs a living ecosystem. Think of it like a woman nurturing life: when an object is added, itβs not just stored, it evolves. Hands, eyes, and a voice, their functionality emerges naturally as the system recognizes its identity and extends it. I designed Smart_Store as a womb for intelligent objects. Instead of rigid definitions and manual wiring, objects grow their own traits through schema awareness, custom type registration, and multi-format serialization, all written in pure, raw C++20. Undo/redo, thread safety, migration, itβs all embedded, not bolted on. This isnβt just engineering, itβs biological architecture. I wanted every interaction with the system to feel organic, reactive, alive. And the result? A framework that thinks like a developer, behaves like a tool, and responds like a living system.
- Safe, maintainable item storage using
std::shared_ptr - Tag-based lookup for fast item retrieval
- Undo/redo history for state management
- Import/export across JSON, XML, CSV, and Binary formats
- Clean schema migration for legacy upgrades
- Thread-safe operations
- Extensible custom type registration via templates
- Built with modern C++ idioms (RAII, STL, type safety)
- Uses
std::shared_ptrfor all items - No raw pointers exposed
- Ownership fully managed internally
- Undo/redo operates on deep clones
- Snapshots stored as deep clones
-
undo()andredo()for safe state traversal - Clear separation of history stacks
- Mutex locks (
std::lock_guard<std::mutex>) for safe concurrent access - Read/write operations protected
- Thread-safe API prevents race conditions
- Built-in
MigrationRegistrysystem - Versioned upgrades of legacy JSON data on import
- Gradual migration strategies (e.g., v1 β v2 β v3)
- Reduces data corruption and incompatibility
| Format | Import | Export | Notes |
|---|---|---|---|
| JSON | β | β | Human-friendly |
| CSV | β | β | Interop with Excel |
| XML | β | β | Human-readable |
| Binary | β | β | Compact & fast |
Main Components:
| Component | Role |
|---|---|
| ItemManager | Core storage & API interface |
| BaseItem | Abstract base for item types |
| ItemWrapper | Handles serialization metadata |
| Logger | Color logging for clarity |
| MigrationRegistry | Manages version upgrades |
| AtomicFileWriter | Safe file writing utility |
| Json_traits | Type traits for safe, automatic JSON (de)serialization |
- Built-in:
int,std::string,bool - Custom: Any user-defined class registered via
registerType
-
items:std::unordered_map<std::string, std::shared_ptr<BaseItem>>(tag β object) -
idMap: Optional map for reverse-lookup by ID
- Anticipates concurrent access (UI threads, background saves)
- Protects items against simultaneous reads/writes
- Ensures long-term data safety
- Supports evolving needs without breaking data
- Ideal for editors and asset tools
- Encourages experimentation with state safety
- C++20: Modern features, STL, optional, shared_ptr
- nlohmann::json: Intuitive JSON handling
- TinyXML2: Lightweight XML parsing
- ANSI Color Logger: Developer-friendly debugging
- RAII: Automatic resource management
- Single-level undo/redo (future: multi-depth branching)
- Schema migration is JSON-focused (extend to XML/CSV)
- Thread safety is global-lock (potential for finer-grained locking)
- Inventory management systems
- Asset tracking tools
- Game editors
- Data analysis tools with reversible state
- Apps needing cross-format data interoperability
#include "t_manager/ItemManager.h"
struct MyType {
int value;
// ...
};
int main() {
ItemManager manager;
manager.addItem(std::make_shared<MyType>(MyType{42}), "my_tag");
manager.displayByTag("my_tag");
manager.exportToFile_Json("data.json");
manager.undo();
return 0;
}- Add Smart_Store to your CMake project and link dependencies (
nlohmann::json,TinyXML2). - Integration guide
| Method | Description |
|---|---|
addItem(obj, tag) |
Add an item with a tag |
removeByTag(tag) |
Remove item by tag |
displayByTag(tag) |
Display item details |
undo() / redo()
|
Undo/redo last state change |
exportToFile_JSON(filename) |
Export all items to JSON |
importFromFile_JSON(filename) |
Import items from JSON |
registerType<T>() |
Register a custom type |
See source code for full API details.
- Errors are reported via exceptions and color-coded logger output.
- Logging is extensible; you can add custom log levels or output destinations.
- Add new formats by extending import/export methods.
- Implement custom serialization for user types by specializing traits or providing
to_json/from_json. - Schema migration strategies can be customized in
MigrationRegistry.
- Designed for fast lookup and serialization.
- Thread safety uses global mutex; for very large datasets, consider finer-grained locking.
- Undo/redo uses deep clones; optimize for large objects as needed.
- Ask questions, report bugs, or request features via GitHub Issues.
- See README for contribution guidelines.
- MIT License. Contributions welcome!
- See README and LICENSE for details.
- Home
- Integration
- API Guide
- EX/IM-Port Files
- API Thread Access
- Schema & Versioning
- Error Logging Guide
- Global Storage Guide
If you encounter any issues and bugs, please reach out via email or GitHub issues.