Skip to content

Commit

Permalink
Full implementation compiling. Probably doesn't work.
Browse files Browse the repository at this point in the history
  • Loading branch information
dacut committed Jun 13, 2016
1 parent 75f8418 commit 4e3a410
Show file tree
Hide file tree
Showing 5 changed files with 658 additions and 156 deletions.
4 changes: 2 additions & 2 deletions client/ublkdev-c++/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

TARGETS = libublkdev.so ublkdev-s3
CPPFLAGS = -I. -I../../src
CXXFLAGS = -std=c++11 -fPIC -Wall
CXXFLAGS = -std=c++11 -fPIC -Wall -g

LIB_SRCS = ublkdev.cc
LIB_OBJS = $(LIB_SRCS:%.cc=%.o)
LIB_LD = g++
LIB_LDFLAGS = -shared

S3_SRCS = s3.cc
S3_SRCS = regionmap.cc s3.cc
S3_OBJS = $(S3_SRCS:%.cc=%.o)
S3_LD = g++
S3_LDFLAGS = -L.
Expand Down
44 changes: 44 additions & 0 deletions client/ublkdev-c++/regionmap.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <exception>
#include <map>
#include <string>
#include "regionmap.hh"

using std::domain_error;
using std::map;
using std::string;

using Aws::Region;
using Aws::String;

namespace {
class RegionMap {
public:
RegionMap();
map<String, Region> regions;
};

RegionMap::RegionMap() {
regions["us-east-1"] = Region::US_EAST_1;
regions["us-west-1"] = Region::US_WEST_1;
regions["us-west-2"] = Region::US_WEST_2;
regions["eu-west-1"] = Region::EU_WEST_1;
regions["eu-central-1"] = Region::EU_CENTRAL_1;
regions["ap-southeast-1"] = Region::AP_SOUTHEAST_1;
regions["ap-southeast-1"] = Region::AP_SOUTHEAST_2;
regions["ap-northeast-1"] = Region::AP_NORTHEAST_1;
regions["ap-northeast-2"] = Region::AP_NORTHEAST_2;
regions["sa-east-1"] = Region::SA_EAST_1;
return;
}
}

Region getRegionForName(String const &name) {
static RegionMap regionMap;
auto pos = regionMap.regions.find(name);
if (pos == regionMap.regions.end()) {
throw domain_error("Unknown region " + string(name.c_str()));
}

return pos->second;
}

5 changes: 5 additions & 0 deletions client/ublkdev-c++/regionmap.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once
#include <aws/core/Aws.h>
#include <aws/core/Region.h>

Aws::Region getRegionForName(Aws::String const &name);
Loading

0 comments on commit 4e3a410

Please sign in to comment.