C++ :: Boost Memory Mapped Object

Aug 21, 2014

i've created dll and implemented shared memory that every connected process can use. My problem is that i can't change anything in object, which is stored in the memory.

my class :

class MyClass
{
public:
MyClass();
void test();
int counter;
};
void MyClass::test() {
MessageBoxA(NULL, "test", "test", 0x0000000L);
counter++;
}

in stdafx.h i have :

static offset_ptr<MyClass> offset_mt;
static managed_shared_memory *memSegment;

I initialize shared memory and pointer :

memSegment = new managed_shared_memory(create_only, SHARED_MEMORY_NAME, 4096);
offset_mt = memSegment->construct<MyClass>("MyClass myClass")();

And then in an exported function i call

offset_mt.get()->test();

Im calling this from Java using JNA and result is a memory error (Invalid memory access). However, if I delete 'counter++' from test method, everything works fine - message box appears. Is there a limitation that I cant modify objects inside mapped memory or is this done the other way?

View 3 Replies


ADVERTISEMENT

C++ :: Data Buffer With Memory Mapped Files?

Jan 27, 2014

I have a data buffer project in Windows 7 x64 embedded OS (using Visual Studio 2008), that would work simply like that:

One writer application will send data (no network protocols, just procedure call on the same machine) to my app like 20 packages per second, each data packages will be approximately 3 MB size and comes with a timestamp tag.

My application will store each data item for 100 minutes and then remove. (So I can calculate the total size from beginnig no need for dynamic allocation etc...)

Meanwhile there will be up to 5 reader applications which will query data from my app via Timestamp tag and retreive data (no updates or deletitions on data by reader apps).

So since the data in my buffer app can grow over 50GB I don't think that shared memory is going to work for my case.

I'm thinking about using Boost Memory Mapped Files or Windows API Memory Mapped Files.

So theoratically I will crate a fixed size File on harddisk (lets say 50GB) and then map some portion to RAM write the data to this portion, if the reader applications wants to use the data which is mapped currently on memory, then they will use directly, otherwise they will map some other potion of the file to their address spaces and use from there...

My problem is I haven't use Map File concept at all and I'm not a C++ developer so I'm not very familiar with the language fundementals. I've searched tutorials of boost and msdn for windows as well but there is not too much code example.

So I don't know how to map some portion of the data to memory and manage it, also how to search data in file or memory according to the timestamp tag. Yes there are codes for creating files and mapping the whole file to memory but none for dividing it into regions, aligning or padding the data which I need for my case.

View 2 Replies View Related

C++ :: Partially Mapped Crossover

Aug 7, 2012

Worked with genetic algorithms. im solving travelling salesman problem with genetic algorithm and unfortunately stuck at crossover im using partially mapped cross over. i have tried coding it but it some time does not gives valid tour. Looking for building its logic.

View 1 Replies View Related

C++ :: Virtual Function Table Pointer Misplaced In Object Memory

Jul 29, 2014

I have found that when I dump a C++ object from memory to a file - it seems that there is a misplacement of the last Virtual-Function-Table pointer - in that appears at the beginning. The result is that the gdump information based on this object dump (using green hills) is incorrect. I copied the contents of the gdump information below. The executable is compiled in linux.

Basically MEIO::CameraStatus contains an item that relates to its parent class (line 188). Then it has 18 items that are all Diagnostics::EventsCounter items. Now for each Diagnostics::EventsCounter item there is a Virtual-Function-Table Info Pointer as its last item. All is fine and good except that the last item of MEIO::CameraStatus which is _selfReset is missing its last item of 4 bytes (which is the Virtual-Function-Table Info Pointer ). On the other hand - right before the first Diagnostics::EventsCounter item ("_vidErrors") - there is an extra 4 bytes which happens to be the Virtual-Function-Table Info Pointer. As I said the gdump information file does not see this.

Why the object memory "moves" the last Virtual-Function-Table Info Pointer to the beginning (right before _vidErrors) and is there a way to "fix" this?

///////////////////////////////////////////////////////////////////////////
"MEIO::CameraStatus" val:0x000002f0 ind208,-1) Struct-Begin Info
188: "" offset 0, Parent-Class Private Info C++ Struct ref = 114
189: "_vidErrors" offset 160, Member Info C++ Struct ref = 128
190: "_vdiErrors" offset 480, Member Info C++ Struct ref = 128

[Code] .....

View 4 Replies View Related

C++ :: Overloading Stream Operator - Return Memory Address Instead Object

Jul 26, 2012

Try to implement overloading << operator. If I done it void then everything work fine (see comment out) if I make it class of ostream& then the operator return to me some memory address.

Code:
#ifndef Point_HPP // anti multiply including gates
#define Point_HPP
#include <sstream>
class Point {
private:// declaration of private data members
double x;// X coordinate
double y;// Y coordinate

[Code] .....

View 7 Replies View Related

C++ :: Iterate Through Container And Find Value Mapped To A Specific Key

Jan 14, 2014

A C++ container type called std::map is used to store elements that are formed by a combination of key value and mapped value. How do you iterate through this container and find the value mapped to a specific key?

View 3 Replies View Related

C# :: Mapped Network Drive - Deleting Or Moving A File

Sep 16, 2014

Currently I'm trying to do something extremely basic: delete or move a file

I have a mapped network drive (Y) where I have a file I need to move from one folder to another

First was doing the obvious:

System.IO.File.Move("Y:TempFile.txt", "Y:Temp2File.txt");

Not much to go wrong here, right? As long as I have the correct permission to write in the folders and the folders exists, this would normally go smooth. But for some reason it only copies the file. The source file still exists, but it has successfully copied the file to the destination folder. No exceptions has been thrown or anything... but the file still exists in the source directory

I then changed the code to the following:

System.IO.File.Copy("Y:TempFile.txt", "Y:Temp2File.txt");
System.IO.File.Delete("Y:TempFile.txt");
Console.WriteLine("See mommy, no Exceptions");

As expected the file copies correctly, but the delete command is completely ignored. The file is not deleted, but the Console.WriteLine command is called

I'm running the application as the logged in user. The user has permission to delete the file. If I try from Windows Explorer, the file is correctly deleted. Unfortunately my application refuses to delete the file and even worse, it will not even throw an Exception.

View 10 Replies View Related

C++ :: How To Boost Up Execution

Feb 23, 2013

I wrote a program to run long simulations, in one cpu core computation. During the run, I checked the cpu occupation was always around 85%.

Since my simulation took time to run. How can I boost it up to make my cpu run at 100%? Is that because my RAM is not fast enough?

info about my laptop: cpu frequency: up to 3.2 GHz. RAM frequency: 1333 MHz.

View 2 Replies View Related

C++ :: Passing A Reference Of Arg (boost Lib)

Dec 19, 2013

I have in my main(), a function that creates my arg object using boost/program_options.hpp i want to pass this object to another function using templates like this:

Code:
template <typename Targ>
void Count(Targ & arg){
MyObj<string> QueryTab(arg["input-file"].as<string>()); //line number is 352
...
}

However I get an error:

Code:
../include/Filter.hpp: In member function ‘void Count(Targ&)’:
../include/Filter.hpp:352:40: error: expected primary-expression before ‘>’ token
../include/Filter.hpp:352:42: error: expected primary-expression before ‘)’ token
... obviously it does not recognize my intention, what did I do wrong?

View 2 Replies View Related

C++ :: How To Get Boost Libraries To Work With QT IDE

Mar 5, 2013

I have an issue getting boost libraries to work with QT IDE. Here are relevant lines from my .pro file...

INCLUDEPATH += c:/users/bob/desktop/boost_1_53_0/
LIBS += -LC:c:/users/bob/desktop/boost_1_53_0/stage/lib64

After adding #include <boost/filesystem.hpp> I get error...

C:UsersobDesktopqtpuntitled5mainwindow.cpp:3: error: C1083: Cannot open include file: 'boost/filesystem.hpp': No such file or directory

The IDE does not highlight the line. The error only appears on compilation.

View 2 Replies View Related

C++ :: Boost Filesystem Exception

Mar 12, 2014

I have one problem deleting a file with boost. The file is opened in another application and cannot be deleted. I am supposed to received an exception error but I don't get it.

Here is my piece of code, very simple:

bool delete_file(const string &path) {
boost::filesystem::path bpath(path);
try {
if (boost::filesystem::remove(bath)) return true;

[Code] ....

I have put a breakpoint inside the catch part but it does not come to this point. Instead, the the output window of visual studio, I got these lines:

First-chance exception at 0x00007FFD2E575A88 in site_server.exe: Microsoft C++ exception: boost::filesystem::filesystem_error at memory location 0x00000070F8E3E920.
Unhandled exception at at 0x00007FFD2E575A88 in site_server.exe: Microsoft C++ exception: boost::filesystem::filesystem_error at memory location 0x00000070F8E3E920.

How to manage this situation?

View 1 Replies View Related

Visual C++ :: Boost Is Not A Namespace

Nov 29, 2013

exportmain.cpp

Code:
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
// Create an empty property tree object
using boost::property_tree::ptree;
#include "kwxport.h"
#include "resource.h"

[Code] ....

How can I make boost:roperty_tree:tree get recognized by the compiler?

View 2 Replies View Related

Visual C++ :: How To Add Boost Libraries

Oct 1, 2013

i have written an algorithm in VC++ 2010 express edition. i have used the following header files

#include<iostream>
#include<string>
#include<sstream>
#include<ctime>
#include<cassert>
#include<fstream>
#include<vector>

[Code]...

the algorithm worked fine in vc 2010 express edition....

the following header files are not working in vc5

#include<regex>
#include<tuple>
#include<numeric>
#include<unordered_set>
#include "clip.h"

Looks like some of hte boost libraries have to added with vc5.. If any one knows how to add boost libraries with vc5.

showing lot of errors in vc5... not able to run the algorithm in vc5. Our company has only vc5.... the algorithm has to be implemented in vc 2010....

View 2 Replies View Related

C++ :: How To Read Tag Name Of Boost Ptree

Mar 23, 2014

[URL] ....

I wonder how tag reading can be achieved? If say I have a file like

<name>
<firstname>John</firstname>
<surname>Robinson</surname>
</name>

I'd like to read "firstname" or "surname" instead of John or Robinson ....

View 4 Replies View Related

C++ :: Use Boost / Regex For Regular Expressions?

Sep 5, 2013

So I need to use boost/regex for regular expressions. someone told me that it needs to be built. the first problem is boost doesn't tell you how to build it and the second is i did sudo apt-get install libboost something. I don't remember the exact name of the package. it installed but i dont know how i would build it when its installed.

View 2 Replies View Related

C++ :: Error Handling When Using Boost NonCopyable

Aug 2, 2014

I have been using a Boost NonCopyable library in Microsoft Visual Studio 2013.

What I have is the following error message:

Error1error C2280: 'boost::noncopyable_::noncopyable::noncopyable(const boost::noncopyable_::noncopyable &)' : attempting to reference a deleted functionc:usersjohndocumentsvisual studio 2013projectsdonttreaddonttreaddonttread.cpp181DontTread

Now what I want to rectify the error is to throw an exception, so that the program can compile smoothly.

View 4 Replies View Related

C++ :: Static Linking Boost Library

Dec 17, 2014

I have written a program that uses boost in visual studio 2012. The only boost library I used is filesystem by doing.

1)Properties->Linker->General and adding the path or the .lib to the additional dependencies. The libraries, link at compile time.However when i move the exe to a different computer, it doesn't work. Therefore the libraries were dynamically not statically linked. So my question is how do I statically link the filesystem library, so that i can include boost/filesystem.hpp in visual studio 2012?

View 1 Replies View Related

C/C++ :: How To Assign Pointers For Boost Matrix

Aug 4, 2014

I am using boost matrix for generating matrices used for filters. I wan to assign a pointer to these matrices so i can call them out of the function. but i am not able to understand where i am failing. the example code is here.

int main(int argc, char *argv[]) {
QApplication a(argc, argv);
identity_matrix<double> M(3);
std::cout<<M<<std::endl;

[Code] ....

View 9 Replies View Related

C/C++ :: Linking Boost Thread With Xcode

Sep 30, 2014

I have built Boost from the website using

./bootstrap.sh
./b2 install

I think all are installed properly. I am trying to use Xcode to include the library of boost:thread.My code links to the header file properly with " #include "boost/thread.hpp"" commented, as seen from the following:

However, it could not link properly to boost-thread if "#include "boost/thread.hpp"" is un-commented.

Error page is shown as:

I have linked the dynamic library libboost_thread.a and libboost_thread.dylib and included /usr/local/include into header search path and /usr/local/lib into library search path.

View 1 Replies View Related

C++ :: Listing Files With Boost Filesystem

Jun 7, 2013

I have the following code which is based of the tut3.cpp example at: [URL] ....

However, I'm not entirely sure how to retrieve the full file path which I'd like to use to get the file size. So essentially the aim is to go through a directory and list all the file sizes.

Code:
if (exists(p)) {
if (is_directory(p)) {
cout << p << " is a directory containing:
";
copy(directory_iterator(p), directory_iterator(), // directory_iterator::value_type

[Code] ....

View 1 Replies View Related

C++ :: Mesh Array Of Double Boost

Jul 11, 2012

I wanna create mesh Array using boost elements, that will be do the same that code below, but can accept numbers of double. Any boost array that give me needed functionality. It will be great that advised element has the same argument list. I mean

// [base,stride,bound)
// [0,2,4)

Or may be there are any opportunity modify this boost::multi_array_types::index_range in order do make it accept double...

1>------ Build started: Project: HP_A.1_d_, Configuration: Debug Win32 ------
1> Main.cpp
1>c:all myс++ha level 9solutionlevel 9hp_a.1_d_main.cpp(15): warning C4244: 'argument' : conversion from 'double' to '__w64 int', possible loss of data
1>c:all myс++ha level 9solutionlevel 9hp_a.1_d_main.cpp(15): warning C4244: 'argument' : conversion from 'double' to '__w64 int', possible loss of data
1>c:all myс++ha level 9solutionlevel 9hp_a.1_d_main.cpp(18): warning C4244: 'argument' : conversion from 'double' to 'unsigned int', possible loss of data
1>c:all myс++ha level 9solutionlevel 9hp_a.1_d_main.cpp(20): warning C4244: 'argument' : conversion from 'double' to 'unsigned int', possible loss of data
1>c:all myс++ha level 9solutionlevel 9hp_a.1_d_main.cpp(20): warning C4244: 'argument' : conversion from 'double' to 'unsigned int', possible loss of data
1> HP_A.1_d_.vcxproj -> C:all myс++HA level 9SolutionLevel 9DebugHP_A.1_d_.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Code:
#include <boostmulti_array.hpp>
#include <iostream>
typedef boost::multi_array_types::index_range range;

[Code]....

View 1 Replies View Related

C++ :: Accessing Array In A Thread (boost)

Nov 22, 2012

I was wondering if it was possible to access data from an array inside a threaded function after it has finished executing?

Take this example:

Code:
#include <iostream>
#include <boost/thread.hpp>
using namespace std;

[Code]....

After workerFunc has finished, how could I access the array arr? Is there any way to get (3,4,5,6,7) back into main()?

View 5 Replies View Related

C++ :: Unable To Get Random Numbers Using Boost In A Class

Apr 24, 2014

I have been working with and trying to understand Boost for random number generating. I've come to understand that what I want is now in the C++11 standard, but I've stuck with Boost.

What I have done is create a simple main.cpp that generated random numbers successfully. From there I wanted to create a more optimal system by separating out the random code portion to a class that can be instantiated and called on demand. My problem now is that when I call the random routine of the class I just get one number no matter how many times it's called.

I know that rapid seeding is an issue so I put the seed function of the random portion in the class's constructer so that it is only called once on the creation of a class. I also tried making it a static member, but I haven't had success with that yet either. For now though, I would simply like to get successive random values upon calling the class's random function.

class header Code: #ifndef roomGen_hpp_
#define roomGen_hpp_
#include"boost/random.hpp"
#include"main.hpp"
class
roomGen
{
private:
boost::mt19937rngDimensions;

[code].....

The main.hpp file only contains a couple of struct definitions. In main I call the class with Code: randomRooms.push_back(randRooms.createRoom()); to get back a struct with random values and push it into a vector.

I'm unsure what I'm doing wrong here to only get back a single non random number from successive calls. I have tried moving the variable creation lines from roomGen::createRoom() to the private area of the class definition, but that causes me to get a slew of undefined errors so I had to settle on putting those declarations inside the function.

View 4 Replies View Related

C++ :: How To Create Unique Types Like That Of Boost Files

Apr 5, 2013

I've been studying metaprogramming and reviewing many documents and code regarding boost files. What I've been trying to understand and accomplish is creating various types using typedef, template and struct, similar to that of the boost files themselves, to create comparators. Ultimately, I want to be able to create a type that has sub-properties which can be further compared and classified.

Informal example:

create type
typedef int coordinate[3];
create standards - "typeless prototypes"
static const coordinate _x = {1,0,0};
static const coordinate _y = {0,1,0};
static const coordinate _z = {0,0,1};

We "now have" three variables under one unique type. Now I want to wrap this further to work with other types (int, float, etc.).

create special cases

template<class ty, coordinate c> struct coord_type;
typedef coord_type<int,x> x_i;
typedef coord_type<float,x> x_f;
typedef coord_type<int,y> y_i;
typedef coord_type<float,y> y_f;
typedef coord_type<int,z> z_i;
typedef coord_type<float,z> z_f;

declare more standards

const x_i i_i;
const x_f i_f;
const y_i j_i;
const y_f j_f;
const z_i k_i;
const z_f k_f;

Where other variables can be represented based off this i,j,k standard and written in a more direct vector form.

And so on...

What I essentially would like to do is have x,y,z variables act as standards for an i,j,k system that classify arbitrary variables of the coordinate type: Is the arbitrary variable i, j, or k? Is it defined as an int or float type?

Where arguments such as sum_y = var1 + var2; are valid, provided:
sum_y is outputted as 6j, and var1 and var2 are 2j and 4j, respectively.

View 9 Replies View Related

C++ :: Boost Binding - Comparing String Using Strcmp

Jun 5, 2014

I am trying to compare strings (char*) using strcmp but I am having a hard time doing it with boost::bind. It compiles but it crashes when I run it.

I have a std::vector<boost::shared_ptr<DeviceInfo>> cMonitoredDevices and one cCurrentDevices. I used a typedef DeviceContainer for std::vector<boost::shared_ptr<DeviceInfo>>.

DeviceInfo is a simply struct that contains a char[128] Name (and other fields not important for this issue) that I want to use to compare.

So I am trying to find the DeviceInfo (based on Name) that are in cMonitoredDevice but not in cCurrentDevices. My problem is retrieving the Name value for the strcmp. Here is what I have so far

for(DeviceContainer::iterator pDevice = m_cMonitoredDevices.begin();
pDevice != m_cMonitoredDevices.end(); pDevice++) {
if (std::find_if(cCurrentDevices.begin(), cCurrentDevices.end(),
boost::bind(&strcmp, boost::bind(&boost::shared_ptr<DeviceInfo>::value_type::Name, _1),
(*pDevice)->Name) == 0) == m_cMonitoredDevices.end()) {
}
}

View 2 Replies View Related

C++ :: Compiling Static Version Of Boost Libraries?

Mar 6, 2013

I have been trying to compile a static version of the boost libraries, however when I try to launch the program it says fatal error LNK1104: cannot open file 'libboost_serialization-vc100-mt-s-1_53.lib'

I have checked in the boost/stage/lib folder and that file is not there. I compiled boost with b2 link=static yet the file still isn't there.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved