Commit 5f03993f authored by Arnaud Blanchard's avatar Arnaud Blanchard

chage get_all_infos

parent 5af6f93d
......@@ -21,7 +21,7 @@ src/blc_channel.cpp
src/channel_file.cpp
)
add_definitions(${BL_DEFINITIONS} -std=c++14 -fdiagnostics-color=always)
add_definitions(${BL_DEFINITIONS} -std=c++14 -pedantic -fdiagnostics-color=always)
include_directories(include ${BL_INCLUDE_DIRS})
#shared lib
......
......@@ -26,10 +26,10 @@
#include <semaphore.h>
#ifdef __cplusplus
#include <map>
#include <string>
#include <utility> //pair
#include <vector>
#endif
/**\mainpage Summary
......@@ -152,8 +152,7 @@ typedef struct blc_channel
bool operator<(blc_channel &b);
static std::pair<blc_channel*, int> get_all_infos(std::string filter="");
static void update_all_infos(std::vector<blc_channel> &channels, std::string filter="");
static void get_all_infos(std::map<int, blc_channel> &channels, std::string filter="");
#else
{
......@@ -226,6 +225,9 @@ typedef struct blc_channel
int blc_channel_get_all_infos_with_filter(blc_channel **channels_infos, char const *start_name_filter);
///Retrieve the informations about a channel if it is known and return the id. Otherwise, return -1. You need to free .dims, which is allocated to contain the list of blc_dims.
int blc_channel_get_info_with_name(blc_channel *info, char const *name);
///Remove the blc_channel **name**. The other processes using it will still work but no new ones can use it.
void blc_remove_channel_with_name(char const *name);
......
......@@ -33,6 +33,8 @@
#include <sys/time.h> //gettimeofday
#include <semaphore.h>
#include <algorithm> //std:strcopy
#include <map> //std:strcopy
#include "blc_core.h"
#define TMP_BUFFER_SIZE 4096
......@@ -580,8 +582,8 @@ pair<vector<int>, vector<int>> blc_channel::get_update_infos(vector<blc_channel>
}
}
fclose(file);
}
*/
}*/
pair<blc_channel*, int> blc_channel::get_all_infos(string filter){
auto channels_nb=0;
blc_channel channel_info;
......@@ -601,3 +603,41 @@ pair<blc_channel*, int> blc_channel::get_all_infos(string filter){
fclose(file);
return make_pair(channels_infos, channels_nb);
}
/*
pair<unique_ptr<vector<blc_channel>new_channels>,unique_ptr<vector<blc_channel*> removed_channels>> blc_channel::update_infos(map<int, blc_channel> &channels, string filter){
blc_channel channel_info;
FILE *file;
unique_ptr<vector<blc_channel>*> new_channels;
unique_ptr<vector<blc_channel>> removed_channels;
file=fopen(BLC_CHANNELS_LIST_PATH, "r");
if (file == nullptr) {
removed_channels->insert(removed_channels->begin(), channels);
channels.clear();
return make_pair(make_unique<vector<blc_channel*>>, removed_channels);
}
auto it=channels.begin();
while(fscanf(file, "%*[ \t\n]s")!=EOF){
channel_info.fscan_info(file, 1);
if (filter.empty() || strcmp(filter.data(), channel_info.name)==0){
while (it->first < channel_info.id){
channels.erase(it);
it++;
}
if (it->first != channel_info.id) {
channels.emplace(channel_info.id, channel_info);
channel_info.dims=nullptr; //Avoid dims to be removed by the destructor or fscan_info
}
it++;
}
}
while (it!=channels.end()){
channels.erase(it);
it++;
}
fclose(file);
}
*/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment