Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions mock_pdi/pdi.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,18 @@ typedef enum PDI_status_e {
PDI_ERR_PERMISSION,
PDI_ERR_RIGHT = PDI_ERR_PERMISSION,
PDI_ERR_TYPE,
PDI_ERR_INVALIDACTION,
PDI_ERR_MULTIPLE,
PDI_NB_STATUSES_DEFINED
} PDI_status_t;

static
#ifdef __cplusplus
constexpr
#endif
char const * const PDI_STATUS_MSG[PDI_NB_STATUSES_DEFINED]
= {"", "", "", "", "", "", "", "", "", "", "", ""};

typedef void (*PDI_errfunc_f)(PDI_status_t status, const char* message, void* context);

typedef struct PDI_errhandler_s {
Expand Down
3 changes: 2 additions & 1 deletion pdi/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Benoit Martin - CEA (bmartin@cea.fr)
* Add support for const data in `PDI_share`, `PDI_expose` and `PDI_multi_expose`

Jacques Morice - CEA (jacques.morice@cea.fr)
* Add Add operator== in Context::Iterator()
* Add operator== in Context::Iterator()
* Delay data events in multi_expose when the last data is exposed

François-Xavier Mordant - CEA (francois-xavier.mordant@cea.fr)
* Fixed CMake issues, internal API enhancement
Expand Down
13 changes: 13 additions & 0 deletions pdi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ and this project adheres to
* added a `ENABLE_BENCHMARKING` flag to cmake to enable running the benchmarks
as part of the tests (off by default)
[#679](https://github.com/pdidev/pdi/issues/679)
* Improved messages for specification tree errors, with file & line numbers and
support for file names from Paraconf 1.1,
[#657](https://github.com/pdidev/pdi/issues/657)
* A new error code `PDI_ERR_INVALIDACTION` has been added when an action
requested in the yaml specification tree makes no sense (but the specification
tree in syntaxically correct)
* A new error code `PDI_ERR_MULTIPLE` has been added when multiple errors of
different kind happen
* `PDI_STATUS_MSG` has been added to offer an english description of error
codes.

#### Changed
* The minimum version of C required is now C17 (ISO/IEC 9899:2018) instead of
Expand All @@ -28,6 +38,8 @@ and this project adheres to
usages [#675](https://github.com/pdidev/pdi/issues/675)
* benchmarks are not run as part of the test suite by default anymore, one must
set `ENABLE_BENCHMARKING` to `ON` in Cmake to re-enable them
* Delay data events in multi_expose when the last data is exposed
[#514](https://github.com/pdidev/pdi/issues/514)

#### Deprecated
* Error names have been improved to fix
Expand Down Expand Up @@ -60,6 +72,7 @@ and this project adheres to

#### Removed
* `PDI::Unavailable_error` was never used and has been removed.
* `PDI::Error` is now an abstract class and should never be used directly.

#### Fixed

Expand Down
1 change: 1 addition & 0 deletions pdi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ set(PDI_C_SRC
src/data_descriptor_impl.cxx
src/datatype.cxx
src/datatype_template.cxx
src/delayed_data_callbacks.cxx
src/error.cxx
src/expression.cxx
src/expression/impl.cxx
Expand Down
8 changes: 4 additions & 4 deletions pdi/docs/Doxyfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (C) 2024 Commissariat a l'energie atomique et aux energies alternatives (CEA)
# Copyright (C) 2024-2026 Commissariat a l'energie atomique et aux energies alternatives (CEA)
#
# All rights reserved.
#
Expand Down Expand Up @@ -33,7 +33,7 @@ ALLEXTERNALS = NO
ALLOW_UNICODE_NAMES = NO
ALPHABETICAL_INDEX = YES
ALWAYS_DETAILED_SEC = NO
AUTOLINK_IGNORE_WORDS =
AUTOLINK_IGNORE_WORDS = PDI
AUTOLINK_SUPPORT = YES
BINARY_TOC = NO
BRIEF_MEMBER_DESC = YES
Expand Down Expand Up @@ -90,7 +90,7 @@ EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
EXCLUDE =
EXCLUDE_PATTERNS =
EXCLUDE_SYMBOLS =
EXCLUDE_SYMBOLS = *::impl, *::impl::*
EXCLUDE_SYMLINKS = NO
EXPAND_AS_DEFINED =
EXPAND_ONLY_PREDEF = YES
Expand Down Expand Up @@ -175,7 +175,7 @@ HTML_OUTPUT = @CMAKE_CURRENT_BINARY_DIR@/html
HTML_PROJECT_COOKIE =
HTML_STYLESHEET = @CMAKE_CURRENT_SOURCE_DIR@/_template/style.css
IDL_PROPERTY_SUPPORT = YES
IGNORE_PREFIX =
IGNORE_PREFIX =
IMAGE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/images
IMPLICIT_DIR_DOCS = NO
INCLUDED_BY_GRAPH = NO
Expand Down
25 changes: 24 additions & 1 deletion pdi/include/pdi.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,33 @@ typedef enum PDI_status_e {
PDI_ERR_RIGHT PDI_ERR_RIGHT_DEPRECATED = PDI_ERR_PERMISSION,
/// Invalid type error
PDI_ERR_TYPE,
/// The amount of distinct error codes defined. This should always remain last and not be used as an error code
/// Action described in the specification tree is invalid
PDI_ERR_INVALIDACTION,
/// Multiple errors of different types append
PDI_ERR_MULTIPLE,
/// The amount of distinct error codes defined. This should not be used as an error code
// it should also always remain last
PDI_NB_STATUSES_DEFINED
} PDI_status_t;

static
#ifdef __cplusplus
constexpr
#endif
char const * const PDI_STATUS_MSG[]
= {"Not an error",
"Data unavailable",
"Invalid entry in specification tree",
"Invalid value expression",
"Invalid plugin",
"Missing feature",
"System error",
"Precondition not respected",
"Permission issue",
"Incorrect type",
"Invalid action requested",
"Multiple errors"};

/** Type of a callback function used when an error occurs
* \param status the error code
* \param message the human-readable error message
Expand Down
25 changes: 22 additions & 3 deletions pdi/include/pdi/data_descriptor.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (C) 2015-2024 Commissariat a l'energie atomique et aux energies alternatives (CEA)
* Copyright (C) 2015-2026 Commissariat a l'energie atomique et aux energies alternatives (CEA)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -78,21 +78,40 @@ class PDI_EXPORT Data_descriptor
*/
virtual bool empty() = 0;

/** Shares some data with PDI
/** Shares some data with PDI and callbacks on the data will be trigger inside this function
* \param[in,out] data the shared data
* \param read whether read access is granted to other references
* \param write whether write access is granted to other references
*/
virtual void share(void* data, bool read, bool write) = 0;

/** Shares some data with PDI
/** Shares some data with PDI and callbacks on the data will be trigger outside this function
* \param[in,out] data the shared data
* \param read whether read access is granted to other references
* \param write whether write access is granted to other references
* \param delayed_callbacks a list of callbacks where the callback for this data will be added,
* instead of being triggered. So that one can delay the trigger
*/
virtual void share(void* data, bool read, bool write, Delayed_data_callbacks&& delayed_callbacks) = 0;

/** Shares some data with PDI and callbacks on the data will be trigger inside this function
* \param[in,out] ref a reference to the shared data
* \param read whether the stored reference should have read access
* \param write whether the stored reference should have write access
* \return the just shared buffer
*/
virtual void* share(Ref ref, bool read, bool write) = 0;

/** Shares some data with PDI and callbacks on the data will be trigger outside this function
* \param[in,out] ref a reference to the shared data
* \param read whether the stored reference should have read access
* \param write whether the stored reference should have write access
* \param delayed_callbacks a list of callbacks where the callback for this data will be added,
* instead of being triggered. So that one can delay the trigger
* \return the just shared buffer
*/
virtual void* share(Ref ref, bool read, bool write, Delayed_data_callbacks&& delayed_callbacks) = 0;

/** Releases ownership of a data shared with PDI. PDI is then responsible to
* free the associated memory whenever necessary.
*/
Expand Down
70 changes: 70 additions & 0 deletions pdi/include/pdi/delayed_data_callbacks.h
Comment thread
jmorice91 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*******************************************************************************
* Copyright (C) 2026 Commissariat a l'energie atomique et aux energies alternatives (CEA)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of CEA nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/

#ifndef PDI_DELAYED_DATA_CALLBACK_H_
#define PDI_DELAYED_DATA_CALLBACK_H_

#include <string>
#include <vector>

#include <pdi/pdi_fwd.h>
#include "pdi/context.h"

#include "global_context.h"

namespace PDI {

class PDI_EXPORT Delayed_data_callbacks
{
/// list of names of the data
std::vector<std::string> m_datanames;

/// The context where the list of data is a part of
Global_context& m_context;
Copy link
Copy Markdown
Contributor

@JAuriac JAuriac Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe shouldn't use a Global_context directly, and should remove the direct include to global_context.h, to go through Context instead with virtuals

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. We must not use Global_context directly. This variables is not defined in the "pdi/include"
We have three options:

    1. Use instead the class Context as you propose (implemented and tested but not commited yet).
    1. Do a virtual class Delayed_data_callbacks and put the implementation in the src as Data_descriptor
      and use Global_context in implementation
    1. Do a virtual class Delayed_data_callbacks and put the implementation in the src as Data_descriptor
      and use Context in the implementation


public:
/// constructor
Delayed_data_callbacks(Global_context& ctx);

Delayed_data_callbacks(const Delayed_data_callbacks&) = delete;

Delayed_data_callbacks(Delayed_data_callbacks&&) = delete;

/// In the destructor, we need to throw an error message in case the callback on the data doesn't work (trigger function)
/// (example: error in the config.yml for a plugin, error due to external library incompatibility)
~Delayed_data_callbacks() noexcept(false);

/// add element "name" to "m_datanames"
void add_dataname(const std::string& name);

/// Trigger data callback for all elements in "m_datanames"
void trigger();

/// clear m_datanames
void cancel();

}; // class Delayed_data_callbacks

} // namespace PDI
#endif // PDI_DELAYED_DATA_CALLBACK_H_
Loading